———

 
Translations of this page:

Configuration Examples

Single template dir

When having single template dir, set subtemplateDir to false

$c = CascadedTemplate::getDefaultConfig();
$c->mainDir = PROJECT_DIR.'/tpl';
$c->subtemplateDir = false; // we only have one template dir
$c->setTplPath($c->mainDir, 'tpl');
$c->webPath = '/';
$c->reportUndefinedVariables = false;
$c->useModRewrite = true;
// equivalent to:
//$c->tplRootDir = $c->mainDir;
$c->tplRootDir = $c->mainDir;
CascadedTemplate::initDefaultHtmlProcessors(false);
CascadedTemplate::addDefaultProcessor(new ConstantProcessor());

Multi-teplate dir

Becareful with the case in this setup!!!

$c->mainDir = PROJECT_DIR.'/tpl/maintpl';
$c->subtemplateDir = PROJECT_DIR.'/tpl/user/template1'; // we only have one template dir
$c->setTplPath(PROJECT_DIR.'/tpl', 'tpl');
$c->webPath = '/';
$c->reportUndefinedVariables = false;
$c->useModRewrite = true;
// equivalent to:
//$c->tplRootDir = $c->mainDir;
$c->tplRootDir = $c->mainDir;
CascadedTemplate::initDefaultHtmlProcessors(false);
CascadedTemplate::addDefaultProcessor(new ConstantProcessor());
 
//Make sure to use different namespace when having multiple templates in a project
$cache = new \nsfw\cache\MemCache('project-name:tpl-name-or-id', $memcacheSettings);

Multi-Language setup

To initialize multi-language support pass true

CascadedTemplate::initDefaultHtmlProcessors(true);
 
nsfw3/tutorials/cascadedtemplate/configuration.txt · Last modified: 01.06.2021 16:15 by npelov
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki