Adding different CSS files to different pages in Orchard CMS?

落花浮王杯 提交于 2019-12-22 10:19:45

问题


Let's say we have two pages in Orchard CMS. The homepage and the About US page. I want to use a RoyalSlider on the homepage which has its own CSS file. How do I include it only on the homepage and not on the about us page?

In Orchard CMS I am using Contoso as the theme and I tried including the royalslider.css file on the Layout.cshtml using Style.Include but this will include the CSS file over all the pages in the website which is not a good practice.


回答1:


You should use URL Alternates feature for that. It's described here, in the section "URL and Widget Alternates".

After enabling the feature, copy the Layout.cshtml you found in your theme and rename it to Layout-url-homepage.cshtml. This one will only be used for rendering the homepage, so just add your Style.Include calls there and you're set.




回答2:


You can try 2 things.

  1. Use the Classy feature in Vandaley Industries module (http://gallery.orchardproject.net/List/Modules/Orchard.Module.Vandelay.Industries). Then you can add a script to any content type.

  2. Create an alternate at the corresponding URL.

They are many other ways, as Orchard is SOOOO extensible. Try these two first. :)



来源:https://stackoverflow.com/questions/12854474/adding-different-css-files-to-different-pages-in-orchard-cms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!