Best method to add Kentico default bootstrap and jquery to a Portal engine template

David Pearson asked on August 6, 2014 16:50

I am attempting to use the Portal Engine for creating my templates. I created my template and got jquery and bootstrap css working while I am log into the Kentico.

However if I use a different browser to view the site the jquery and bootstrap does not load. What is the best method to include those files on front end?

Thanks David

Correct Answer

Brenden Kehren answered on August 6, 2014 17:51

On the master page, I use the Head HTML code webpart and simply add a link to your stylesheet in there.

<link href="/CMSPages/GetResource.ashx?stylesheetname=YourStyleSheetCodeName" type="text/css" rel="stylesheet"/>

This example is using a stylesheet created in the CSS Stylesheet app, if you want to use the bootstrap css, you can link to the local copy Kentico offers or use one in the cloud, simply change your url.

Same is true for your JS files. In the same webpart or add a new one, simply add

<script src="/CMSPages/GetResource.ashx?scriptfile=/CMSScripts/Custom/Sitename/jquery.js" type="text/javascript"></script>

and you're set.

This way you don't have to worry about IIS loading CSS files when you don't want and you can still use the out of the box functionality.

1 votesVote for this answer Unmark Correct answer

Recent Answers


David Pearson answered on August 6, 2014 17:57

Thanks, I was thinking this was the only way.

David

1 votesVote for this answer Mark as a Correct answer

Luis Lugo answered on August 22, 2014 20:45

Will this download duplicates when on-site page editing is enabled or will the GetResource handler take care of that?

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.