Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

Different CSS for Different Pages


Reply


2 Posts   745 Views

Avatar
mango82

Community Member, 3 Posts

9 June 2011 at 5:50pm

I'm trying to use different CSS for different pages, e.g.

home.css -> home page
interior.css ->about us

Is there a way I can tell which page I'm on and call which css?

Thanks in advance..

Avatar
Willr

Forum Moderator, 5513 Posts

9 June 2011 at 6:57pm

Is there a way I can tell which page I'm on and call which css?

You can use $URLSegment, or $ClassName to check for whatever you want. http://doc.silverstripe.org/sapphire/en/reference/built-in-page-controls#urlsegment

In your case you may want do try something like

<% if URLSegment = home %>
<% require themedCSS('home') %>
<% else %>
<% require themedCSS('interior') %>
<% end_if %>