Page 1 of 1

different stylesheet for each page

Posted: Tue Jan 29, 2008 10:40 pm
by Lateralus
Hi all!

Let's say my menu is as following:

-Home
-Company
-Ideas
-Contact

and i want for each menu item (only the first level in the menu) a different style sheet. So Home has stylesheet 1, company has stylesheet 2 and so on... I want to use this so each page has it's own div border collor's for example. I know a workaround; give each page a different template en give each of those templates a different stylesheet... but the negative side of this workaround is when you want to change your HTML, you have to do that for 4 templates...

What is a good way to do this?

Thanks in advance!!

Greetz,

Johan

Re: different stylesheet for each page

Posted: Tue Jan 29, 2008 11:27 pm
by calguy1000
Well, there are a few ways to do this, depending upon how many different styles you want to apply to each page


Lets assume you have this hierarchy:
  Home
  Page 1  (alias 1)
      Page 1.1
      Page 1.2
  Page 2 (alias 2)
      Page 2.1
      Page 2.2
  Page 3 (alias 3)
      Page 3.1
      Page 3.2
      Page 3.3

And you want all of the Page3 pages to include a different stylesheet than all the page2 pages do, and different again from all the page1 pages.  What I'd suggest you do is this:

1) Install the CGSimpleSmarty module
2) Create new stylesheets and name them according to the page alias name of the root page of all of your subsections
3) add content like this into the head part of your page template
{stylesheet name=$cgsimple->get_root_alias()}

with this syntax, a different stylesheet would be attached according to the root page alias of whatever page the user is on.

Re: different stylesheet for each page

Posted: Sat Feb 02, 2008 2:59 pm
by Lateralus
thank you very mucht calguy! i'll check it out