Send a variable from a controller, to view, to css-file |
[eluser]Unknown[/eluser]
Hello everybody! I've been using CodeIgniter for quite some time now..I think about six months. I really like its straightforwardness and extendability. Today I was using it on a new project of mine. This project is a simpel CMS-system, with a front and a backend. In the backend I have a page where users can select a main color for the website (I used http://code.google.com/p/mcolorpicker/ for this). When submitted, the color is stored in a database. Next stop, the front. I have a controller that gets this color from the model and stores it in a variable. This var gets send to the view and I loop through it to use this color on several items on a page - like hyperlink, menu background, logo, etc. For now this approach works fine, but I was wondering if it was possible to send the variable, from the controller to the view, which sends it to a css-file. Thanks in advance!
[eluser]iloveci[/eluser]
I believe there is some major failure of logic going on here. I'm unsure why your trying to send variables to your css file. I believe what you want is a base CSS file, that handles all the styling of the elements on your page, Then additional color-specific css files. So then when you need to change from say red to blue, use php to load blue.css instead of red.css. Does this make sense?
[eluser]Unknown[/eluser]
Well, it does make more or less sense, but what you are suggesting, actually limits my options of available color selection. Either that, or I should generate a whole lot of css-files. In a previous project, which was pre-CodeIgniter, I generated a css-file, which I renamed to a .php-file. Then I added a constant like so: Code: <?php However, adding constants to a css file, generates on error. That is why I was wondering if it possible to send a variable to a css file. Thanks again for your help.
[eluser]eggzy[/eluser]
Take a look at http://net.tutsplus.com/tutorials/php/su...-the-hood/ |
Welcome Guest, Not a member yet? Register Sign In |