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

Found a bug in template library, when set theme is not call might cause error

Open keatliang2005 opened this issue 14 years ago • 3 comments

when it's not call $this->template->set_theme($theme) on controller,

and the configuration default theme is set to $config['theme'] = $theme;

libraries/Template.php#L80 at line 80 will cause the problem, due to for-loop ascending nature

foreach ($config as $key => $val) { if ($key == 'theme' AND $val != '') { $this->set_theme($val); // executed at first because $config['theme'] first continue; }

$this->{'_'.$key} = $val; //then $config['theme_locations'] is the last statement }

sorry for my bad english. ;-)

keatliang2005 avatar Nov 09 '10 12:11 keatliang2005

I think you and I found the same issue. This should be fixed in changeset 22a6dcdfc4787171a9aa Can you re-download and test it out?

dfreerksen avatar May 04 '11 13:05 dfreerksen

I think that this issue still slightly exists :-( It appears that although the set_theme() call is being made, it is completley ingnored when handling the layouts.

For example, in my controller i have: $this->template->set_theme('mytheme')->set_layout('lays')->build('myview', $data);

When building, it is trying to build the layout located at "views/layouts/lays.php" instead of "themes/mytheme/layouts/lays.php" (ive altered the core to find out what file its trying to load)\

Im looking into the problem right now, but any suggestions would be greatley appreciated.

James

JANorman avatar May 11 '11 08:05 JANorman

JANorman, if you look closely at the get_theme_layouts() function and _find_view_folder() Template is looking for the layout files within [themes dir]/mytheme/views/layouts/layoutfile.php. The 'views' folder inbetween the theme folder and the layouts folder isn't immediately obvious.

I found the documentation to be a bit inconsistent and had to resort to the code to work that out.

I hope that helps.

jessedc avatar Jun 28 '11 03:06 jessedc