本文整理匯總了PHP中Phalcon\Mvc\View::setTemplateBefore方法的典型用法代碼示例。如果您正苦於以下問題:PHP View::setTemplateBefore方法的具體用法?PHP View::setTemplateBefore怎麽用?PHP View::setTemplateBefore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Phalcon\Mvc\View
的用法示例。
在下文中一共展示了View::setTemplateBefore方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: registerServices
/**
* Registers services related to the module
*
* @param DiInterface $di Dependency Injection Container
*/
public function registerServices(DiInterface $di)
{
/**
* Read configuration
*/
$config = (require __DIR__ . "/config/config.php");
/**
* Setting up the view component
*/
$di->setShared('view', function () {
$view = new View();
$view->setViewsDir(__DIR__ . '/views/');
$view->setTemplateBefore('main');
$view->registerEngines([".volt" => function ($view, $di) {
$volt = new Volt($view, $di);
$volt->setOptions(['compiledPath' => function ($templatePath) {
return realpath(__DIR__ . "/../../var/volt") . '/' . md5($templatePath) . '.php';
}, 'compiledExtension' => '.php', 'compiledSeparator' => '%']);
return $volt;
}]);
return $view;
});
/**
* Database connection is created based in the parameters defined in the configuration file
*/
$di->setShared('db', function () use($config) {
return new Connection(['host' => $config->database->host, 'username' => $config->database->username, 'password' => $config->database->password, 'dbname' => $config->database->dbname]);
});
}
示例2: _getViewDisabled
protected function _getViewDisabled($level = null)
{
$view = new Phalcon\Mvc\View();
$view->setViewsDir('unit-tests/views/');
$view->setTemplateAfter('after');
$view->setTemplateBefore('before');
if ($level !== null) {
$view->disableLevel($level);
}
$view->start();
$view->render('test13', 'index');
$view->finish();
return $view;
}
示例3: _getViewDisabled
protected function _getViewDisabled($level = null)
{
$view = new View();
$view->setViewsDir(PATH_DATA . "views" . DIRECTORY_SEPARATOR);
$view->setTemplateAfter("after");
$view->setTemplateBefore("before");
if ($level !== null) {
$view->disableLevel($level);
}
$view->start();
$view->render("test13", "index");
$view->finish();
return $view;
}