Adding CSS and JS resource files into nopCommerce Plugin documentation inaccurate?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 year ago
Hi Team,
I recently used the documentation for adding css to specific pages in a plugin, but doing so does not work.
My code is as follows:

@inject INopHtmlHelper NopHtml
@{
    Layout = "_ColumnsTwo";

    NopHtml.AppendPageCssClassParts("html-account-page");
    NopHtml.AddCssFileParts(ResourceLocation.Head, "~/Plugins/Widgets.MyWidget/Content/css/style.css", excludeFromBundle: false);
}

And the error comes at the `ResourceLocation.Head` part:
void INopHtmlHelper.AddCssFileParts(string src, [string debugSrc = ""], [bool excludeFromBundle = false])

I am developing in nop 4.5.0, so is there a breaking change with this advice between 4.5 and 4.6? Or is there something else I am doing wrong?
1 year ago
Hi

you can try this it may be helpful to you

@inject INopHtmlHelper NopHtml
@{
    Layout = "";
    NopHtml.AppendScriptParts(ResourceLocation.Footer, "~/lib_npm/jquery-ui-dist/jquery-ui.min.js");
    NopHtml.AppendCssFileParts("~/Plugins/Widgets.MyWidget/Content/css/style.css", excludeFromBundle: false);
}
<script asp-exclude-from-bundle="true" src="/Plugins/Widgets.MyWidget/Content/css/style.css" asp-location="Footer"></script>


I have added 2 example
one is related to JS and one is CSS

and you can check with NivoSlider Plugin they have used like this please check the ScreenShot
1 year ago
Unfortunately, only one of the three proposed methods worked.
For js copying NivoSlider worked, but for the css file none of those methods mentioned worked. Using F12 dev tools on the page shows that the css file is not being picked up at all afaict.
1 year ago
General Peaceful wrote:
Unfortunately, only one of the three proposed methods worked.
For js copying NivoSlider worked, but for the css file none of those methods mentioned worked. Using F12 dev tools on the page shows that the css file is not being picked up at all afaict.


Okay, re-engaged my brain, and the `AppendCssFileParts` solution does work. Thank you!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.