Smarty::setConfigDir PHP Method

setConfigDir() public method

Set config directory
public setConfigDir ( $config_dir ) : Smarty
return Smarty current Smarty instance for chaining
    public function setConfigDir($config_dir)
    {
        $this->config_dir = array();
        foreach ((array) $config_dir as $k => $v) {
            $this->config_dir[$k] = str_replace(array('//', '\\\\'), DS, rtrim($v, '/\\')) . DS;
        }
        $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir);
        return $this;
    }

Usage Example

Example #1
0
 /**
  * Initialize the view
  * Require the class to have an instance of the provider
  *
  * @param string $templateFolder Optional template folder to use instead of the default /frontend/module/views/
  * @return Viewable
  */
 protected function initializeView($templateFolder = null)
 {
     if (!$this->view) {
         $this->view = new \Smarty();
         $configuration = $this->getConfiguration();
         $appFolder = $configuration->get('system.app.folder');
         if ($templateFolder === null) {
             $module = $this->getModuleFromNamespace();
             $templateFolder = $appFolder . '/frontend/' . $module . '/views/';
         }
         // setup the template folder
         $this->view->setTemplateDir($templateFolder);
         // setup the temporary folders
         $tempFolder = $configuration->get('system.temp.folder');
         $this->view->setCompileDir($this->checkWritable($tempFolder . '/smarty_compiled/'));
         $this->view->setCacheDir($this->checkWritable($tempFolder . '/smarty_cache/'));
         $this->view->setConfigDir($this->checkWritable($tempFolder . '/smarty_config/'));
         // add all the plugin folders to the view
         foreach ($configuration->get('view.plugin.folders', array()) as $pluginFolder) {
             $this->view->addPluginsDir($pluginFolder);
         }
         $this->view->addPluginsDir($appFolder . '/../vendor/mystlabs/mistyforms/src/MistyForms/smarty_plugins');
         $this->view->addPluginsDir($appFolder . '/../vendor/mystlabs/mistyapp/src/MistyApp/smarty_plugins');
         // if we are in development mode we want to regenerate the views at every render
         if ($configuration->get('system.development.mode', false)) {
             $this->view->compile_check = true;
             $this->view->force_compile = true;
         }
     }
     return $this;
 }
All Usage Examples Of Smarty::setConfigDir