tags:

views:

27

answers:

2

Hi. :)

Apart from the global.css i'm including in my header.php, i would also like to load certain page-content specific styles.

But since my <head></head> is already covered by my header file, and i don't wish to resort to inlines, what is the best way to place the styles on the specific page?

Thanks ! :D

+5  A: 

I would try one of the following:

  1. Break the header.php in 2 distinct files to allow any pages including it to add their own link tags
  2. At the top of the file, before including header.php, set an array like $included_css containing styles (style1.css, style2.css). Then in header.php you can do a simple foreach and include them after global.css (to allow them to take precedence)
nc3b
Worked. Thank you . : )
wretrOvian
Glad it did :-)
nc3b
+3  A: 

in our CMS we have a header folder inside the template directory. If you name a file form.tpl its gonna insert it self only in when form.tpl is called (we handle that with the smarty template engine). What is good practice i think.

An other solution would be to uses classes or id's on your body. <body id="suscribeForm"> and to use them as reference in your css. (the problem is the CSS is loaded even if you don't use it, but on the other side its already cashed if the user changes to an other page).

You can link different CSS files in your main CSS also, but this is not a good practice, because your browser is gonna wait until mains.css is loaded and then load the linked files.

meo