CodeIgniter Forums

Full Version: Dynamic CSS: getting data into the file (again)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]codex[/eluser]
You can put php in a css file by adding header('text/css'), and that all works fine. But I'd like to add <?php base_url()?> (and get data from a db) to the file, but this isn't available in a regular php file. How do you extend the file so that the ci instance is available?

I already asked this question some time ago, but haven't been able to find a solution yet. Here's the original post: http://ellislab.com/forums/viewthread/77954/

El Forum

[eluser]Nick Husher[/eluser]
Could you not have a controller called "css.php" that uses the output class to set Content-type: text/css, then load a view with CSS in it? That would give you access to PHP and CodeIgniter properties.

El Forum

[eluser]codex[/eluser]
[quote author="Nick Husher" date="1220430626"]Could you not have a controller called "css.php" that uses the output class to set Content-type: text/css, then load a view with CSS in it? That would give you access to PHP and CodeIgniter properties.[/quote]

Yes, that's exactly what I did just now :-)