Home > DeveloperSection > Forums > In Orchard cms I want to include certain .js files, where should i put them and how should i include it in my project?
Mark Devid
Mark Devid

Total Post:102

Points:714
Posted on    June-06-2013 2:38 AM

 JavaScript JavaScript 
Ratings:


 1 Reply(s)
 4140  View(s)
Rate this:
Hi Developers,

In Orchard cms I want to include certain .js files, where should I put them and how should I include it in my project? I am using "TheThemeMachine" as the theme of my project, so I created a folder js and clubed all the .js files require to me in this folder. Now in my Layout.cshtml

I have included in this manner my other .js files But it gives me error in console that

mywebsite/Themes/TheThemeMachine/js/jquery-1.8.0.min.js 404 (Not Found)

Please help,
Thanks in advance. 


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    June-06-2013 8:22 AM

Hi Expert,

To include script files first put you'r script in Scripts directory then simply try following

Script.Include("jquery-1.8.0.min.js");

By the way , this is not the correct way of including Jquery library in your theme. Jquery have been registered as a global resource with Orhard.jQuery module thus to include jquery try this :

Script.Require("jQuery");

this will ensure that jQuery included only once.but if you insist in putting script files in js directory then you can try this trick.

Script.Include("../js/yourscript.js");

don't forget to put a copy of web.config (one exist in Scripts directory) file in your js directory unless you'r script file will never been detected.

edit :

making change to ThemeMachine is not a good habit.try creating your own theme based onThemeMachine by orchard command line .this is the way to go :

codegen theme <theme-name> [/CreateProject:true|false][/IncludeInSolution:true|false][/BasedOn:<theme-name>]  
for example :

codegen theme MyTheme /CreateProject:true /IncludeInSolution:true /BasedOn:

TheThemeMachine orchard command line is an exe file resides in /bin directory. this will create Scripts and Styles directory automatically.


Don't want to miss updates? Please click the below button!

Follow MindStick