To be clear, depending on your situation, there are several methods. I will talk about the most common I know.
First of all, there is the inclusion of an external script or style sheet in your specific part or theme. The standard syntax in the Razor template is as follows:
@Style.Include("YourPartEdit") @Script.Require("jQuery") @Script.Include("YourPartEdit")
Incoming files will look for this specific resource in the corresponding Style or Scripts folder: for @Script.Include("YourPartEdit") it will look in the scripts folder for YourPartEdit.js .
You may have noticed that with Script.Require you can register a library with Orchard (in this case, registered jQuery ) and call the required specific script for the module.
To do this, you create your own implementation of the IResourceManifestProvider interface and implement the BuildManifests(ResourceManifestBuilder builder) method and create a named resource. You can use .AtFoot() or .AtHead() to achieve the goal, where it will go.
Now say you want to link to a particular image, and you want to use Razor to always specify the correct image URL. First of all, I recommend placing the image in your Content folder for your theme (provided that it is an image related to the theme), and you will do something in this direction:
<img src=@Url.Content (Html.ThemePath(WorkContext.CurrentTheme, "/Content/your-logo.png")) />
Now, let's say this is on your Layout.cshtml page - now you can successfully use the image anywhere in the site.
These specific methods must take into account many situations.
source share