本文整理汇总了PHP中Smarty::getTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty::getTemplate方法的具体用法?PHP Smarty::getTemplate怎么用?PHP Smarty::getTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty
的用法示例。
在下文中一共展示了Smarty::getTemplate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_template
/**
* @param null $template
* @param null $cache_id
* @param null $compiled_id
* @param null $parent
* @return string
*
* @throws \SmartyException
*/
public function get_template($template = null, $cache_id = null, $compiled_id = null, $parent = null)
{
$this->init_engine();
$this->template_engine->setCompileDir($this->compile_dir);
foreach ($this->template_dirs as $i => $dir) {
$i == 0 && $this->template_engine->setTemplateDir($dir);
$i > 0 && $this->template_engine->addTemplateDir($dir);
}
$this->load_lang_vars($this->get_lang_file());
return $this->template_engine->getTemplate($template, $cache_id, $compiled_id, $parent);
}
示例2: show_error
public static function show_error($message)
{
/**
* @var $system \System
*/
$system = Application::get_class(\System::class);
$smarty = new \Smarty();
$smarty->setTemplateDir($system->get_path() . DS . 'templates');
$smarty->setCompileDir($system->get_path() . DS . 'templates_c');
$error_class = 'error-block';
$params = ['class' => $error_class, 'message' => $message];
$smarty->assign($params);
echo $smarty->getTemplate('message.tpl.html');
}
示例3: show_result
protected function show_result(GetResponse $response)
{
/**
* @var $template Template
*/
$template = Application::get_class(\Starter::class);
$smarty = new \Smarty();
$bundle_file = ROOT_PATH . DS . 'static_builder' . DS . 'bundle.result.json';
$bundle_result = json_decode(file_get_contents($bundle_file), true);
$smarty->assign('bundle_result', $bundle_result);
if (strpos(Request::uri(), 'admin_panel') !== false) {
$smarty->setTemplateDir($template->get_path() . DS . 'templates' . DS . 'admin_panel');
} else {
$smarty->setTemplateDir($template->get_path() . DS . 'templates' . DS . 'site');
}
$smarty->setCompileDir($template->get_path() . DS . 'templates_c');
$smarty->assign($response->blocks);
$smarty->assign('title', new PageTitle());
echo $smarty->getTemplate('index' . DS . 'index.tpl.html');
}
示例4: show_result
private function show_result()
{
/**
* @var $view ExtensionView
*/
$view = Application::get_class(LeftMenuView::class);
$this->response->blocks['left'] = $view->render();
$view = Application::get_class(TopMenuView::class);
$this->response->blocks['top'] = $view->render();
$smarty = new \Smarty();
$bundle_file = ROOT_PATH . DS . 'static_builder' . DS . 'bundle.result.json';
$bundle_result = json_decode(file_get_contents($bundle_file), true);
$smarty->assign('bundle_result', $bundle_result);
$smarty->assign($this->response->blocks);
/**
* @var $ext \Tools
*/
$ext = Application::get_class(\Tools::class);
$smarty->setTemplateDir($ext->get_path() . DS . 'templates' . DS . 'index');
$smarty->setCompileDir($ext->get_path() . DS . 'templates_c');
echo $smarty->getTemplate('index.tpl.html');
}