codeigniter-twiggy
codeigniter-twiggy copied to clipboard
Setting a theme doesn't work correctly
I have created 2 themes - default and admin. the following code doesn't output the admin theme:
$this->twiggy->theme('admin'); // load theme echo $this->twiggy->get_theme(); // this returns 'admin' - which is correct $this->twiggy->display(); // outputs default theme not admin - incorrect
FYI - I uncommented line 457 in the Twiggy lib - method _set_template_locations. Functionality now works.
// Reset template locations array since we loaded a different theme $this->_template_locations = array(); // UNCOMMENTED THIS LINE
Thank you for your feedback. I'll look into this when I have the time.
This was the solution for me, I changed lines ~478 :
$this->_template_locations[] = $this->_themes_base_dir . $theme;
$this->_template_locations = array_reverse($this->_template_locations);
even though i dont see a need to set(change) theme multiple times, reversing the array is a bad idea.
array_unshift($this->_template_locations, $this->_themes_base_dir . $theme); //$this->_template_locations[] = $this->_themes_base_dir . $theme;
and maybe add array_unique()
to the mix
@lewispb thanks for the solution. @veljamatic I would like to know why do you think that isn't a good idea?
In my case I also need more than one theme because I have different themes for the public site and private/admin site.