CodeIgniter Forums
Easiest Way to Handle Multiple View Styles? - 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: Easiest Way to Handle Multiple View Styles? (/showthread.php?tid=8252)



Easiest Way to Handle Multiple View Styles? - El Forum - 05-11-2008

[eluser]Aea[/eluser]
I'm working on a site right now where I want to have two view styles, one for normal pages, and one "minimal" view for inclusion in javascript modal windows.

What would be the best way to pass a variable to every single controller so I could get around this issue?


Easiest Way to Handle Multiple View Styles? - El Forum - 05-12-2008

[eluser]gtech[/eluser]
If the template is select by the user,
the easiest way to store and retrieve variables that are available across page requests is to use the session library, this is well documented in the CI documentation.

if the template is selected by a permanent config value then take a look at the config class:
[url="http://ellislab.com/codeigniter/user-guide/libraries/config.html"]http://ellislab.com/codeigniter/user-guide/libraries/config.html[/url]
You can add your own variables to the config/config.php file


Easiest Way to Handle Multiple View Styles? - El Forum - 05-12-2008

[eluser]Aea[/eluser]
I'm sorry, I must have explained it in a confusing manner. I want to pass an variable (as simple as /m/ or the lack of it) within the context of the url, and I want to know what the easiest way to get it across all sorts of controllers would be (obviously without setting it up as a controller variable for every function).


Easiest Way to Handle Multiple View Styles? - El Forum - 05-12-2008

[eluser]wiredesignz[/eluser]
Take a look at the URI Language Identifier library, it provides an automatic key that is added to all site_url()'s and could be easily modified to suit your application.


Easiest Way to Handle Multiple View Styles? - El Forum - 05-12-2008

[eluser]Aea[/eluser]
Thank you, that was exactly what I was looking for Smile