philsturgeon / codeigniter-template

Template library for CodeIgniter which supports modules, themes, partial views, etc.
411 stars 178 forks source link

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

Open keatliang2005 opened 13 years ago

keatliang2005 commented 13 years ago

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

dfreerksen commented 13 years ago

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

JANorman commented 13 years ago

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

jessedc commented 13 years ago

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.