Template path is not set correctly when configure slim after initialization
Hello.
Probably following case is a bug. When you initialize
Slim and than (after) you will try to configure it and
set new 'templates.path' than in rendering process the path will be
still './templates'. Example:
$app = new Slim(); if ($app instanceof Slim)
{
$app->config(
array(
'templates.path' => './app/styles/',
'smarty_compile_path' => './app/styles/compiled/',
'smarty_cache_path' => './app/styles/cache/',
'view' => new SmartyView()
)
);
}
It is because only in the new Slim() process the
setTemplatesDirectory method of Slim_View
class is invoked. And it is not invoked by the
$app->config() method.
The quick resolve could be:
-
Add in Slim.php (class:
Slim) something like:public function setTemplatesDirectory($path) { $this->view->setTemplatesDirectory($this->config('templates.path')); } -
After
$app->config(args);add$app->setTemplatesDirectory($app->config('templates.path'));
Comments are currently closed for this discussion. You can start a new one.
2 Posted by Andrew Smith on 21 Feb, 2012 02:26 PM
What version of Slim are you using? This might have been fixed in the upcoming version, can you take a pull from the dev branch and let me know if this is now resolved?
3 Posted by m1chu on 01 Mar, 2012 03:18 PM
Stable: 1.5.0.
4 Posted by Andrew Smith on 09 Mar, 2012 11:05 AM
This has been addressed in the latest develop version. Next release should be fine. You can test by checking out the develop branch on github.
Josh Lockhart closed this discussion on 25 Mar, 2012 03:16 PM.