本文整理汇总了PHP中Smarty::template_exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty::template_exists方法的具体用法?PHP Smarty::template_exists怎么用?PHP Smarty::template_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty
的用法示例。
在下文中一共展示了Smarty::template_exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render($view)
{
if ($this->tpl->template_exists($view)) {
return $this->tpl->fetch($view);
} else {
throw new ViewNotFoundException($view);
}
}
示例2: smarty_insert_block
/**
* Плагин для смарти
* Подключает обработчик блоков шаблона
*
* @param array $aParams
* @param Smarty $oSmarty
* @return string
*/
function smarty_insert_block($aParams, &$oSmarty)
{
/**
* Устанавливаем шаблон
*/
$sBlock = ucfirst(basename($aParams['block']));
/**
* Проверяем наличие шаблона. Определяем значения параметров работы в зависимости от того,
* принадлежит ли блок одному из плагинов, или является пользовательским классом движка
*/
if (isset($aParams['params']) and isset($aParams['params']['plugin'])) {
require_once Config::Get('path.root.server') . '/engine/classes/ActionPlugin.class.php';
$sBlockTemplate = Plugin::GetTemplatePath($aParams['params']['plugin']) . '/block.' . $aParams['block'] . '.tpl';
$sBlockClass = Config::Get('path.root.server') . '/plugins/' . $aParams['params']['plugin'] . '/classes/blocks/Block' . $sBlock . '.class.php';
$sCmd = '$oBlock=new Plugin' . ucfirst($aParams['params']['plugin']) . '_Block' . $sBlock . '($aParamsBlock);';
} else {
$sBlockTemplate = Engine::getInstance()->Plugin_GetDelegate('template', 'block.' . $aParams['block'] . '.tpl');
$sBlockClass = Config::Get('path.root.server') . '/classes/blocks/Block' . $sBlock . '.class.php';
$sCmd = '$oBlock=new Block' . $sBlock . '($aParamsBlock);';
}
if (!isset($aParams['block']) or !$oSmarty->template_exists($sBlockTemplate)) {
$oSmarty->trigger_error("Not found template for block: " . $sBlockTemplate);
return;
}
/**
* параметры
*/
$aParamsBlock = array();
if (isset($aParams['params'])) {
$aParamsBlock = $aParams['params'];
}
/**
* Подключаем необходимый обработчик
*/
require_once $sBlockClass;
eval($sCmd);
/**
* Запускаем обработчик
*/
$oBlock->Exec();
/**
* Возвращаем результат в виде обработанного шаблона блока
*/
return $oSmarty->fetch($sBlockTemplate);
}
示例3: TemplateExists
/**
* Проверяет существование шаблона
*
* @param string $sTemplate
* @return bool
*/
public function TemplateExists($sTemplate)
{
return $this->oSmarty->template_exists($sTemplate);
}
示例4: Smarty
}
$email_message->SetEncodedHeader("Subject", $subject);
/*
* If you are not going to personalize the message body for each recipient,
* set the cache_body flag to 1 to reduce the time that the class will take
* to regenerate the message to send to each recipient
*/
$email_message->cache_body = 0;
/*
* Lets use two distinct Smarty objects for composing the HTML and text
* parts and avoid the need to re-assign constant values when switching
* contexts.
*/
$html_smarty = new Smarty();
$text_smarty = new Smarty();
if (!$html_smarty->template_exists($template = "mailing.html.tpl") || !$text_smarty->template_exists($template = "mailing.txt.tpl")) {
echo "Please copy the template file templates/" . $template . " to your Smarty templates directory.\n";
exit;
}
/* Create empty parts for the parts that will be personalized for each recipient.
* HTML message values should be escaped with HTMLEntities().
*/
$html_smarty->assign("subject", HtmlEntities($subject));
$html_smarty->assign("fromname", HtmlEntities($from_name));
$html_smarty->assign("firstname", "");
$html_smarty->assign("balance", "0");
$html_smarty->assign("email", "?");
$html_message = $html_smarty->fetch("mailing.html.tpl");
$email_message->CreateQuotedPrintableHTMLPart($html_message, "", $html_part);
/*
* It is strongly recommended that when you send HTML messages,
示例5: Smarty
/*
* The form is ready to be processed, just output it again as read only to
* display the submitted values. A real form processing script usually may
* do something else like storing the form values in a database.
*/
$form->ReadOnly = 1;
}
/*
* Create the Smarty engine object to process the form template first
*
* NOTE: the form template needs to be processed separately from any other
* page templates to prevent that the form prefilter interferes with the
* normal processing of the other templates
*/
$smarty = new Smarty();
if ($smarty->template_exists("form.tpl")) {
$smarty->assign_by_ref("form", $form);
$smarty->assign("title", "Form class test");
$smarty->assign("error_message", $error_message);
$smarty->assign_by_ref("verify", $verify);
$smarty->assign("doit", $doit);
$smarty->assign("mark", "[Verify]");
$smarty->assign("credit_card_field", "credit_card_number");
$smarty->register_prefilter("smarty_prefilter_form");
$smarty->fetch("form.tpl");
$smarty->unregister_prefilter("smarty_prefilter_form");
} else {
$form->AddDataPart("<h2><center>Please copy the template file <tt>templates/form.tpl</tt> to your Smarty <tt>templates</tt> directory.</center></h2>\n");
$doit = 1;
}
/*
示例6: template_exists
public function template_exists($resource_name)
{
if (method_exists($this, "templateExists")) {
return $this->templateExists($resource_name);
} else {
return parent::template_exists($resource_name);
}
}