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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Different CSS for Different Pages


Go to End


2 Posts   1436 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, 5523 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 %>