Change stylesheet based on page
Posted: Sat Jul 21, 2007 9:00 pm
Using the sticky post about changing content based on current page as a guide, I put this together:
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:
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.
Code: Select all
{if empty($csstheme)}
{stylesheet name="(default stylesheet name)"}
{else}
{stylesheet name=$csstheme}
{/if}
Code: Select all
{assign var='csstheme' value='(stylesheet name)'}
This code accesses the stylesheets stored in the database, rather than external .CSS files.