CodeIgniter Forums
Dynamic CSS: getting data into the file (again) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Dynamic CSS: getting data into the file (again) (/thread-11295.html)



Dynamic CSS: getting data into the file (again) - El Forum - 09-02-2008

[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/


Dynamic CSS: getting data into the file (again) - El Forum - 09-02-2008

[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.


Dynamic CSS: getting data into the file (again) - El Forum - 09-02-2008

[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 :-)