codeigniter-twiggy icon indicating copy to clipboard operation
codeigniter-twiggy copied to clipboard

Setting a theme doesn't work correctly

Open loopdream opened this issue 11 years ago • 5 comments

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

loopdream avatar Jan 08 '13 11:01 loopdream

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

loopdream avatar Jan 08 '13 11:01 loopdream

Thank you for your feedback. I'll look into this when I have the time.

edmundask avatar Jan 09 '13 08:01 edmundask

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);

lewispb avatar Mar 22 '13 15:03 lewispb

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

veljamatic avatar Jun 16 '13 16:06 veljamatic

@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.

alexhermida avatar Aug 27 '13 09:08 alexhermida