Seperating CSS from PHP scripts
Posted: Wed Mar 05, 2008 5:40 am
One of the undying problems I have faced when coding PHP pages are CSS styles embedded into HTML, which is either echoed out - or returned as string(I usually separate pages into components, and each component will just return the html code that 'renders' it).
I have tried templating (Smarty in particular) and it works fine if you have static component placement and you have a tpl for each page, but I am using a single page system. So it means I need to have a tpl which in the end usually end up looking like this <div style="blah">{$placeholder}</div> just for that particular style. And for each different component, I will need a seperate tpl because there is no saying how many components a page will attach to itself.
Is there any solution to this? Can PHP variables be include in CSS stylesheets somehow so that there will be an automatic sync?
I have tried templating (Smarty in particular) and it works fine if you have static component placement and you have a tpl for each page, but I am using a single page system. So it means I need to have a tpl which in the end usually end up looking like this <div style="blah">{$placeholder}</div> just for that particular style. And for each different component, I will need a seperate tpl because there is no saying how many components a page will attach to itself.
Is there any solution to this? Can PHP variables be include in CSS stylesheets somehow so that there will be an automatic sync?