• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pass variable from Controller to dynamic CSS file?

[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'?

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

<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
$scheme = $_GET['scheme'];

if($scheme == 'alt1'){
    // do some CSS relating to alt1

    // do some other CSS

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.