Welcome Guest, Not a member yet? Register   Sign In
Dynamic CSS - Common approach for code-igniter?
#1

[eluser]sl3dg3hamm3r[/eluser]
Hey there

Here comes right my second question :-)
Additional data like css and images I do store now on the same level as where you would find the system-folder.

But now I encounter the situation where I would like to manipulate some variables in css, before it is sent to the browser. E.g. if there is a background-picture defined which is language-depending, I need to set that picture first with code-igniter.

What is there the approach? Shall I treat in that case CSS as a view? Or what are the common approaches here in that case?

Any tipps highly appreciated! Smile
Oliver
#2

[eluser]Hannes Nevalainen[/eluser]
I have a css-controller thats
is outputing a css-file which I'm including in my main view. You can easily pass data as uri segments or pull data from your database.

Code:
<link rel="stylesheet" type="text/css" href="<?=site_url('css')?>" />

Enable caching if your css controller while not developing, then the overhead added by having php to output your css is reduced.

Happy Coding! //Hannes
#3

[eluser]Mirage[/eluser]
You certainly can just make your CSS file a view and inject PHP that way.

I'd say it all depends on what and how much you want to make dynamic. An alternate approach might be to override default/static css rules by injecting them into a page header or inline.

For the language example I usually define css for each language - overriding rules in the default css and inject which language to load right into the page header:

Code:
<link rel="stylesheet" type="text/css" href="/css/default.css">
<link rel="stylesheet" type="text/css" href="/css/<?=$lc ?>.css">

HTH,
m
#4

[eluser]sl3dg3hamm3r[/eluser]
thank you for the inputs - I gonna try out some more as soon as I'm back from holydays :-)

happy coding!




Theme © iAndrew 2016 - Forum software by © MyBB