Template path is not set correctly when configure slim after initialization

m1chu's Avatar

m1chu

17 Feb, 2012 08:09 AM via web

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

  1. 2 Posted by Andrew Smith on 21 Feb, 2012 02:26 PM

    Andrew Smith's Avatar

    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?

  2. 3 Posted by m1chu on 01 Mar, 2012 03:18 PM

    m1chu's Avatar

    Stable: 1.5.0.

  3. 4 Posted by Andrew Smith on 09 Mar, 2012 11:05 AM

    Andrew Smith's Avatar

    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.

  4. Josh Lockhart closed this discussion on 25 Mar, 2012 03:16 PM.

Comments are currently closed for this discussion. You can start a new one.

Recent Discussions

17 May, 2012 04:51 PM
17 May, 2012 01:17 PM
17 May, 2012 12:22 AM
17 May, 2012 12:05 AM