Pass variable from Controller to dynamic CSS file? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Pass variable from Controller to dynamic CSS file? (/showthread.php?tid=50141) |
Pass variable from Controller to dynamic CSS file? - El Forum - 03-15-2012 [eluser]Sven Delle[/eluser] I need to pass a variable to a dynamic CSS file. Can this be done in CI? I've tried setting a $_SESSION['variable'] in the controller and call it from a CSS file (style.php with a header type of text/css), but I get nothing (and yes, I did session_start()). Does this clash with CI's built in session handling, and can I at all use CI's session in files external to the 'system'? How do I go about this 'problem'? Pass variable from Controller to dynamic CSS file? - El Forum - 03-17-2012 [eluser]fuchong[/eluser] I'm not sure about how CI sessions and non-CI sessions work but what about the following? Since the PHP files that you're calling are outside of the CI structure, they can accept query strings. Why not append a query string at the end and just use $_GET to grab what you want. For example inside you're CI view Code: <link type="text/css" media="screen" rel="alternate stylesheet" title="Color Scheme #1" href="css-demo.php?scheme=alt1" /> And inside your dynamic CSS file Code: $scheme = $_GET['scheme']; |