How to call js and css files?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
2 anos atrás
Hi All
I have custom JS and CSS files. I want to call it in PaymentInfo.cshtml

The path of the CSS file ./Content/cssfile.css
The path of the JS file ./Scripts/jsfile.js

@{
    Layout = "";
    //Loading CSS file
    Html.AddCssFileParts("~/Plugins/pluginname/Content/cssfile.css");
    //Loading js file
    //Third parameter value indicating whether to exclude this script from bundling
    Html.AddScriptParts("~/Plugins/pluginname/Scripts/jsfile.js");
}
put didn't work with me. Any advice?
nopcommerce 4.40.
2 anos atrás
Mybe you need to exclude them from the bundle

    Html.AddCssFileParts("~/Plugins/Payments.Laybuy/Content/styles.css", excludeFromBundle: true);

This code is from https://github.com/nopSolutions/laybuy-plugin-for-nopcommerce/blob/nopCommerce-4.40/Nop.Plugin.Payments.Laybuy/Views/PriceBreakdown/_view.cshtml

Are you using One Page Checkout ?
If so then turn that off and see if what you are doing works
If so - Then if you still need to use OPC there a method to load scripts using
HandleEventAsync(PageRenderingEvent eventMessage)
2 anos atrás
Yidna wrote:
Mybe you need to exclude them from the bundle

    Html.AddCssFileParts("~/Plugins/Payments.Laybuy/Content/styles.css", excludeFromBundle: true);

This code is from https://github.com/nopSolutions/laybuy-plugin-for-nopcommerce/blob/nopCommerce-4.40/Nop.Plugin.Payments.Laybuy/Views/PriceBreakdown/_view.cshtml

Are you using One Page Checkout ?
If so then turn that off and see if what you are doing works
If so - Then if you still need to use OPC there a method to load scripts using
HandleEventAsync(PageRenderingEvent eventMessage)


Thank you for your reply
I was trying do what you see But still didn't work.
2 anos atrás
S-a-A wrote:
Hi All
I have custom JS and CSS files. I want to call it in PaymentInfo.cshtml

The path of the CSS file ./Content/cssfile.css
The path of the JS file ./Scripts/jsfile.js

@{
    Layout = "";
    //Loading CSS file
    Html.AddCssFileParts("~/Plugins/pluginname/Content/cssfile.css");
    //Loading js file
    //Third parameter value indicating whether to exclude this script from bundling
    Html.AddScriptParts("~/Plugins/pluginname/Scripts/jsfile.js");
}
put didn't work with me. Any advice?
nopcommerce 4.40.


It's solved. Simply used

<link href="~/Plugins/Payments.PluginName/Content/cssfile.css" rel="stylesheet" />
<script type="text/javascript" src="~/Plugins/Payments.PluginName/Scripts/jsfile.js"></script>
2 anos atrás
S-a-A wrote:
Hi All
I have custom JS and CSS files. I want to call it in PaymentInfo.cshtml

The path of the CSS file ./Content/cssfile.css
The path of the JS file ./Scripts/jsfile.js

@{
    Layout = "";
    //Loading CSS file
    Html.AddCssFileParts("~/Plugins/pluginname/Content/cssfile.css");
    //Loading js file
    //Third parameter value indicating whether to exclude this script from bundling
    Html.AddScriptParts("~/Plugins/pluginname/Scripts/jsfile.js");
}
put didn't work with me. Any advice?
nopcommerce 4.40.


In NopCommerce 4.40 plugin this works fine for me.
   
Html.AddScriptParts(ResourceLocation.Footer, "~/Plugins/pluginname/Scripts/jsfile.js");
Html.AddCssFileParts("~/Plugins/pluginname/Content/cssfile.css");


Please check the path from the network tab of the browser if the path had been pointed properly.
2 anos atrás
jayadul wrote:

In NopCommerce 4.40 plugin this works fine for me.
   
Html.AddScriptParts(ResourceLocation.Footer, "~/Plugins/pluginname/Scripts/jsfile.js");
Html.AddCssFileParts("~/Plugins/pluginname/Content/cssfile.css");


Please check the path from the network tab of the browser if the path had been pointed properly.



Hi,

it works in 4.40 but not in 4.50.
Why?


Best regards
2 anos atrás
eproline wrote:

In NopCommerce 4.40 plugin this works fine for me.
   
Html.AddScriptParts(ResourceLocation.Footer, "~/Plugins/pluginname/Scripts/jsfile.js");
Html.AddCssFileParts("~/Plugins/pluginname/Content/cssfile.css");


Please check the path from the network tab of the browser if the path had been pointed properly.


Hi,

it works in 4.40 but not in 4.50.
Why?


Best regards


Hi,

i found the problem, that is now in nop 4.50
NopHtml.AddCssFileParts("~/Plugins/.../css/style.css");
Unfortunately, NopCommerce has not changed the documentation.

  Best regards
2 anos atrás
Didn't have to try with 4.50 yet. Thanks for sharing.
2 anos atrás
epl-software wrote:

Hi,

i found the problem, that is now in nop 4.50
NopHtml.AddCssFileParts("~/Plugins/.../css/style.css");
Unfortunately, NopCommerce has not changed the documentation.

  Best regards


Oh, we'll fix it soon. Thank you!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.