本文整理汇总了PHP中modExtraManagerController::fetchTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP modExtraManagerController::fetchTemplate方法的具体用法?PHP modExtraManagerController::fetchTemplate怎么用?PHP modExtraManagerController::fetchTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modExtraManagerController
的用法示例。
在下文中一共展示了modExtraManagerController::fetchTemplate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchTemplate
/**
* Override parent function.
* Override Smarty. I don't wants it. But BEWARE: the loadHeader and loadFooter bits require
* the functionality of the original fetchTemplate function. ARRRGH. You try to escape but you can't.
*
* @param string $file (relative to the views directory)
* @return rendered string (e.g. HTML)
*/
public function fetchTemplate($file)
{
// Conditional override! Gross!
// If we don't give Smarty a free pass, we end up with "View file does not exist" errors because
// MODX relies on the parent fetchTemplate function to load up its header.tpl and footer.tpl files. Ick.
if (substr($file, -4) == '.tpl') {
return parent::fetchTemplate($file);
}
$this->modx->log(\modX::LOG_LEVEL_DEBUG, 'File: ' . $file, '', 'BaseController::' . __FUNCTION__);
$path = $this->modx->getOption('assman.core_path', '', MODX_CORE_PATH . 'components/assman/') . 'views/';
$data = $this->getPlaceholders();
$this->modx->log(\modX::LOG_LEVEL_DEBUG, 'View: ' . $file . ' data: ' . print_r($data, true), '', 'BaseController::' . __FUNCTION__, 'Line:' . __LINE__);
if (!is_file($path . $file)) {
$this->modx->log(\modX::LOG_LEVEL_ERROR, 'View file does not exist: ' . $file, '', 'BaseController::' . __FUNCTION__, 'Line:' . __LINE__);
return $this->modx->lexicon('view_not_found', array('file' => 'views/' . $file));
}
// Load up our page [header] + content + [footer]
ob_start();
if (!isset($this->scriptProperties['_nolayout'])) {
$this->modx->log(\modX::LOG_LEVEL_DEBUG, 'Including header.php', '', 'BaseController::' . __FUNCTION__, 'Line:' . __LINE__);
include $path . 'header.php';
}
include $path . $file;
if (!isset($this->scriptProperties['_nolayout'])) {
$this->modx->log(\modX::LOG_LEVEL_DEBUG, 'Including footer.php', '', 'BaseController::' . __FUNCTION__, 'Line:' . __LINE__);
include $path . 'footer.php';
}
$content = ob_get_clean();
return $content;
}