Using latest version CMSMS
I need to use a different stylesheet for certain pages. Is there any way to associate a stylesheet apart from the simple adding of, and associating with, a template?
Thanks
[Solved]Adding different stylesheet for certain pages
[Solved]Adding different stylesheet for certain pages
Last edited by jasnick on Sat Mar 05, 2011 6:27 am, edited 1 time in total.
Re: Adding different stylesheet for certain pages
Usage for {cms_stylesheet} is in the help. Extensions -> Tags -> cms_stylesheet
If you really want to be fancy, you can define a one-line content block where the page editor can enter the stylesheet name, or leave it blank, and the value can be used to select a stylesheet, or add another one.
If you really, really want to be fancy, you can use AdvancedContent and define a multi-select with the stylesheets for the editor to select from.
Code: Select all
{if $page_alias == 'home'}
{cms_stylesheet name='home_stylesheet'}
{/if}
If you really, really want to be fancy, you can use AdvancedContent and define a multi-select with the stylesheets for the editor to select from.
Re: Adding different stylesheet for certain pages
Thanks Wishbone - didn't think of looking there - SO much to learn!
Not looking to get too fancy!!
if $page_alias == 'home'}
Are the two == correct or is that a typo? Not meaning to be rude
So I set up a new stylesheet in the usual way, associate it with the template, and put the following in the head:
{if $page_alias == 'home'}
{cms_stylesheet name='secondstylesheet'}
{/if}
and repeat if more than one page will use this stylesheet. Is that correct? I leave the current stylesheet {stylesheet} in the head as is?
Not looking to get too fancy!!
if $page_alias == 'home'}
Are the two == correct or is that a typo? Not meaning to be rude

So I set up a new stylesheet in the usual way, associate it with the template, and put the following in the head:
{if $page_alias == 'home'}
{cms_stylesheet name='secondstylesheet'}
{/if}
and repeat if more than one page will use this stylesheet. Is that correct? I leave the current stylesheet {stylesheet} in the head as is?
Re: Adding different stylesheet for certain pages
yes.. == is correct.
If you're using {stylesheet} for your main template css, then use {stylesheet name="secondstylesheet"} instead of {cms_stylesheet} to be consistent.
{cms_stylesheet} has a caching mechanism, and exists in /tmp, so you have to adjust your image URLs. {stylesheet} is in your document root ( / )
If you're using {stylesheet} for your main template css, then use {stylesheet name="secondstylesheet"} instead of {cms_stylesheet} to be consistent.
{cms_stylesheet} has a caching mechanism, and exists in /tmp, so you have to adjust your image URLs. {stylesheet} is in your document root ( / )
Re: Adding different stylesheet for certain pages
Thanks - haven't quite got it working yet but can now see why. Will follow your instructions and mark this solved if I can get it working.
Yes, lost my background image, saw the error in the path and was wondering what to do next!
Thanks again!
Yes, lost my background image, saw the error in the path and was wondering what to do next!
Thanks again!
Re: Adding different stylesheet for certain pages
Thanks Wishbone - I've now got it all working!
Re: [Solved]Adding different stylesheet for certain pages
You can also add style sheets to the metadata box in options tab when editing/making pages...
Re: [Solved]Adding different stylesheet for certain pages
That's interesting - thanks Dr.CSS