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   740 Views

Avatar
mango82

9 June 2011 at 5:50pm Community Member, 3 Posts

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

9 June 2011 at 6:57pm Forum Moderator, 5511 Posts

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 %>