Close

Scripts don't seem to load

dimitritroncquo
7 years ago
#12953 Quote
Avatar
  • 8
Hi,

I'm having some trouble getting the ribbons to work in nopCommerce 3.8. They work fine in the DefaultClean theme, but with our own customized version of this same theme, the scripts don't seem to load.



Other sevenspikes plugins, like ajaxfilters and prev/next however work fine.

I must say we kind of butchered the theme, so maybe we deleted a necessary section or dom-element or whatever. I tried to track down this mysterious omission, but I havn't been able to pinpoint it.

What sections, widgetzones, etc. does the ribbons plugin rely on to be loaded?

You can check the dev site at http://chocdecor.lodestar.be/choctales/top-selection. The products in this category should all have a ribbon.

Our content and templates are partially loaded from Umbraco, but this shouldn't really make a difference I think. It just explains why we maimed the theme the way we did :)

The /choctales is because we run a multistore on a single domain using a reverse proxy. The stores are actually on two "virtual" domains known only locally to the server. In IIS we use two applications under a single website to avoid naming conflicts. Both point to the same actual application. This all sounds a bit complex probably, and I don't think this is what causes the issue. We don't have trouble loading other content. When I check the network tab in dev tools, there are no 404's. It looks like the script-tags don't get added to the html.


hristian.dimov
7 years ago
#12955 Quote
Avatar
  • Moderator
  • 386
dimitritroncquo wrote:
Hi,

I'm having some trouble getting the ribbons to work in nopCommerce 3.8. They work fine in the DefaultClean theme, but with our own customized version of this same theme, the scripts don't seem to load.



Other sevenspikes plugins, like ajaxfilters and prev/next however work fine.

I must say we kind of butchered the theme, so maybe we deleted a necessary section or dom-element or whatever. I tried to track down this mysterious omission, but I havn't been able to pinpoint it.

What sections, widgetzones, etc. does the ribbons plugin rely on to be loaded?

You can check the dev site at http://chocdecor.lodestar.be/choctales/top-selection. The products in this category should all have a ribbon.

Our content and templates are partially loaded from Umbraco, but this shouldn't really make a difference I think. It just explains why we maimed the theme the way we did :)

The /choctales is because we run a multistore on a single domain using a reverse proxy. The stores are actually on two "virtual" domains known only locally to the server. In IIS we use two applications under a single website to avoid naming conflicts. Both point to the same actual application. This all sounds a bit complex probably, and I don't think this is what causes the issue. We don't have trouble loading other content. When I check the network tab in dev tools, there are no 404's. It looks like the script-tags don't get added to the html.




Hi,

Product Ribbons plugin is using the "content_before" widget zone to render its info. It is required to have this widget zone. This should be enough. Can you please check if the "content_before" widget zone is available for your theme?

Looking forward to your reply!
Regards,
Hristian Dimov
Nop-Templates.com
dimitritroncquo
7 years ago
#12958 Quote
Avatar
  • 8
@Html.Widget("content_before") is in the template, so that's not the issue.
dimitritroncquo
7 years ago
#12959 Quote
Avatar
  • 8
Here is my _Root.cshtml:


@using Microsoft.Ajax.Utilities
@{
    Html.AppendScriptParts("~/Scripts/public.ajaxcart.js");
    Html.AppendScriptParts("~/Scripts/public.common.js");
    Html.AppendScriptParts("~/Scripts/jquery-migrate-1.2.1.min.js");
    Html.AppendScriptParts("~/Scripts/jquery-ui-1.10.3.custom.min.js");
    Html.AppendScriptParts("~/Scripts/jquery.validate.unobtrusive.min.js");
    Html.AppendScriptParts("~/Scripts/jquery.validate.min.js");
    var slug = Request.RequestContext.RouteData.Values["external-template"] ?? Request.RawUrl;
}
<!DOCTYPE html>
<html>
<head>
    @Html.Action("Head", "ExternalContent", new { slug = slug })
    <!-- @Html.NopTitle() -->
    @Html.NopHeadCustom()
    @Html.Partial("Head")
    @Html.Widget("head_html_tag")
    @Html.NopCssFiles(this.Url, ResourceLocation.Head)
    @Html.NopScripts(this.Url, ResourceLocation.Head)
    <!--Powered by nopCommerce and Umbraco - http://www.nopCommerce.com ; http://www.umbraco.com -->
</head>
<body>
    @Html.Widget("body_start_html_tag_after")
    @Html.Partial("_Notifications")
    @Html.Action("JavaScriptDisabledWarning", "Common")
    @Html.Partial("OldInternetExplorerWarning")
    <div class="master-wrapper-page">
        @Html.Action("AdminHeaderLinks", "Common")
        @Html.Action("Header", "ExternalContent", new { slug = slug })
        @Html.Partial("Header")
        <script type="text/javascript">
            AjaxCart.init(false, '.header-links .cart-qty', '.header-links .wishlist-qty', '#flyout-cart');
        </script>
        <div class="master-wrapper-content">
            @Html.Widget("content_before")
            @Html.Action("Body", "ExternalContent", new { slug = slug })
            @if (IsSectionDefined("Breadcrumb")) {
                @RenderSection("Breadcrumb")
            }
            <div class="master-column-wrapper">
                @RenderBody()
            </div>
            @Html.Widget("content_after")
        </div>
        @Html.Action("Footer", "ExternalContent", new { slug = slug })
    </div>
    @Html.Widget("body_end_html_tag_before")
    @Html.NopCssFiles(this.Url, ResourceLocation.Foot)
    @Html.NopScripts(this.Url, ResourceLocation.Foot)
</body>
</html>

hristian.dimov
7 years ago
#12960 Quote
Avatar
  • Moderator
  • 386
dimitritroncquo wrote:
@Html.Widget("content_before") is in the template, so that's not the issue.


Hi,

I inspected the source code of your webpage and I can see that the necessary code for the product ribbons is there, which means that the plugin is integrated successfully. However, I didn't see the javascript file for the plugin. The interesting thing is that if the <div id="product-ribbon-info"></div> is there, the javascript file should also be there because it is loaded from the same file. This may happen if the javascript file is missing.

Can you please check if the javascript file is uploaded correctly on your server? It should be in this folder: \Plugins\SevenSpikes.Nop.Plugins.ProductRibbons\Scripts\ - ProductRibbons.min.js

Looking forward to your reply!
Regards,
Hristian Dimov
Nop-Templates.com
dimitritroncquo
7 years ago
#12961 Quote
Avatar
  • 8
Hi,

I checked the js file, and it's on the server. Also, there is no 404 for the file, so it's as if it doesn't even get requested.

When I use the defaultclean theme, it works fine, so I must be missing something in our custom theme.
hristian.dimov
7 years ago
#12963 Quote
Avatar
  • Moderator
  • 386
dimitritroncquo wrote:
Hi,

I checked the js file, and it's on the server. Also, there is no 404 for the file, so it's as if it doesn't even get requested.

When I use the defaultclean theme, it works fine, so I must be missing something in our custom theme.


Hi,

I just checked your _Root.cshtml file and I saw that you have combined the "_Root.cshtml" file and "_Root.Head.cshtml" in one file, which I believe is causing the problem.

The javascript file of the plugin is added by the AddScriptParts method in nopCommerce ( Html.AddScriptParts("~/Plugins/SevenSpikes.Core/Scripts/SevenSpikesExtensions.min.js"); ), and later on it should be rendered by the @Html.NopCssFiles(this.Url, ResourceLocation.Head) method.

However, when you open a page with your theme, it will execute the @Html.NopCssFiles(this.Url, ResourceLocation.Head) first and after that, the Product Ribbons plugin will be integrated into the "content_before" zone. But it will be too late for the plugin to insert its own javascript file via AddScriptParts method because the scripts would be already rendered. This is why there are no problems in Default Clean theme.

I suggest you use the Default Clean theme as an example and separate the 2 files that I mentioned above.

Hope this helps!
Regards,
Hristian Dimov
Nop-Templates.com
dimitritroncquo
7 years ago
#12964 Quote
Avatar
  • 8
Hi,

That seems to make sense. I'll try to get everything ordered in the right way and get back to you.

Thank you for your time!
dimitritroncquo
7 years ago
#12967 Quote
Avatar
  • 8
Dear Hristian,

This seems to have fixed the issue. I was able to reorder evrything in the correct way, and it all seems to work fine. I don't quite remember why I combined the files the way I did. I guess it seemed like a good idea at the time. Well, live and learn :)

Thank you very much!

Kind regards,

Dimitri
hristian.dimov
7 years ago
#12970 Quote
Avatar
  • Moderator
  • 386
dimitritroncquo wrote:
Dear Hristian,

This seems to have fixed the issue. I was able to reorder evrything in the correct way, and it all seems to work fine. I don't quite remember why I combined the files the way I did. I guess it seemed like a good idea at the time. Well, live and learn :)

Thank you very much!

Kind regards,

Dimitri


Hi Dimitri,

I'm glad that everything is working fine now!

Have a great day!
Regards,
Hristian Dimov
Nop-Templates.com