Please have a look at the 'Nop.Plugin.ExternalAuth.OpenId' plugin. It has an example of how to add custom CSS and JS: Html.AddCssFileParts(@Url.Content("~/Content/mycustomstyles.css")); Html.AddScriptParts(@Url.Content("~/Scripts/mycustomscripts.js"));
Are you suggesting I need to create a plugin for this? I have looked through the mentioned plugin but don't really understand what to do. I can't even see it including any extra scripts.
It took me a while to work this out and no one was quick to assist so I understand. You can add Css or Javascript links to your head tag by doing the following:
1. Open /Themes/YourTheme/Views/Shared/Head.cshtml
This allows you to add custom links to your website per theme. To do it for all themes you will need to do it in the main head here:
I'm trying to ad the Google Adsense javascript to my 2.80 nopC site. I've tried the ideas in this thread but no go. Google gave me script that looks similar to this, that I must include on my site:
I want to put the ad at the top of every page on my site, so I want this script in the <head/> of every page.
The last thing I tried was to put this script in a separate file, GoogleAdsense.js. Then I added the following line to Head.cshtml: @{ Html.AddScriptParts(@Url.Content("~/Themes/DefaultClean/Content/GoogleAdsense.js")); }
When I run that, I get an ArgumentException in the GenerateScripts() method in PageHeaderBuilder.cs: "The URL '/Themes/DefaultClean/Content/GoogleAdsense.js' is not valid. Only application relative URLs (~/url) are allowed."
I'm trying to ad the Google Adsense javascript to my 2.80 nopC site. I've tried the ideas in this thread but no go. Google gave me script that looks similar to this, that I must include on my site:
I want to put the ad at the top of every page on my site, so I want this script in the <head/> of every page.
The last thing I tried was to put this script in a separate file, GoogleAdsense.js. Then I added the following line to Head.cshtml: @{ Html.AddScriptParts(@Url.Content("~/Themes/DefaultClean/Content/GoogleAdsense.js")); }
When I run that, I get an ArgumentException in the GenerateScripts() method in PageHeaderBuilder.cs: "The URL '/Themes/DefaultClean/Content/GoogleAdsense.js' is not valid. Only application relative URLs (~/url) are allowed."
Can someone assist?
You don't need to use @Url.Content. Just Html.AppendScriptParts("~/Themes/DefaultClean/Content/GoogleAdsense.js");
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.