Page 1 of 1

Change stylesheet based on page

Posted: Sat Jul 21, 2007 9:00 pm
by tam10
Using the sticky post about changing content based on current page as a guide, I put this together:

Code: Select all

{if empty($csstheme)}
    {stylesheet name="(default stylesheet name)"}
{else}
    {stylesheet name=$csstheme}
{/if}
Using this you can change the attached stylesheet per page, without changing template. To use it, put the code above in the template file, below the {metadata} tag. Then in the pages where you want a non-default stylesheet, put the following in the metadata field:

Code: Select all

{assign var='csstheme' value='(stylesheet name)'}
You can use {stylesheet} as well to include stylesheets that are included in all pages. Just remember to remove the one referenced above from the template.

This code accesses the stylesheets stored in the database, rather than external .CSS files.

Re: Change stylesheet based on page

Posted: Thu Jul 26, 2007 8:39 pm
by savagekabbage
Couldn't you also just put a :{stylesheet name='DefaultTheme'} in the page metadata?

Edit: Never mind, I see now that your point is to completely change the associated stylesheets :)