CodeIgniter Forums
how can Multiple Template Directories system - 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: how can Multiple Template Directories system (/showthread.php?tid=11871)



how can Multiple Template Directories system - El Forum - 09-26-2008

[eluser]Blue Sapphire[/eluser]
Hi!
How can I implement multiple templates system. Like in PHPBB, from admin , when admin selects a template, then all front end is converted to that particular template system.

In other words, I want to implement different look and feel of website for different regions, keeping same backend controller.

Can some one guide me in this regards.

Thanks in advance


how can Multiple Template Directories system - El Forum - 09-26-2008

[eluser]Phil Sturgeon[/eluser]
First off, you need a themes folder. Inside that you can put all your css, images and views for each theme.

themes
-- themename
-- -- css
-- -- imgs
-- -- views
etc...

Then in your admin panel somewhere set up a page that returns a list of all themes. One such way is...

Code:
foreach(glob(APP_DIR.'themes', GLOB_ONLYDIR ) as $theme)
$theme_name = basedir($theme);
$themes[$theme_name] = humanize($theme_name];
}

then use that array in a dropdown or whatever and save the theme name in the db somewhere.

Good luck Smile


how can Multiple Template Directories system - El Forum - 09-27-2008

[eluser]Blue Sapphire[/eluser]
Thanks for guidance. But my problem is that, how can programmer/developer can make CI compitible for multiple layouts.

Thanks in advance


how can Multiple Template Directories system - El Forum - 09-27-2008

[eluser]Phil Sturgeon[/eluser]
The last post covered management but not implementation. I remember thinking at the time that may have only been half the picture.

This is the recreated basics, I obviously have this all coded up much nicer.

Code:
$this->load->view('../assets/themes/'.$this->settings->item('default_theme').'/views/layout.php', $data);

Obviously here I am using a my settings library to get the name of the theme we stored in the database before. I use a single layout.php instead of header/footer and pass the page body as a string to this file.

Let me know if you need more!