本文整理匯總了PHP中XoopsTpl::assignByRef方法的典型用法代碼示例。如果您正苦於以下問題:PHP XoopsTpl::assignByRef方法的具體用法?PHP XoopsTpl::assignByRef怎麽用?PHP XoopsTpl::assignByRef使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類XoopsTpl
的用法示例。
在下文中一共展示了XoopsTpl::assignByRef方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: render
/**
* Render the page
* The theme engine builds pages from 2 templates: canvas and content.
* A module can call this method directly and specify what templates the theme engine must use.
* If render() hasn't been called before, the theme defaults will be used for the canvas and
* page template (and xoopsOption['template_main'] for the content).
*
* @param string $canvasTpl The canvas template, if different from the theme default
* @param string $pageTpl The page template, if different from the theme default (unsupported, 2.3+ only)
* @param string $contentTpl The content template
* @param array $vars Template variables to send to the template engine
*
* @return bool
*/
public function render($canvasTpl = null, $pageTpl = null, $contentTpl = null, $vars = array())
{
if ($this->renderCount) {
return false;
}
$xoops = Xoops::getInstance();
$xoops->events()->triggerEvent('core.theme.render.start', array($this));
$cache = $xoops->cache($this->headersCacheEngine);
//Get meta information for cached pages
if ($this->contentCacheLifetime && $this->contentCacheId && ($content = $cache->read($this->contentCacheId))) {
//we need to merge metas set by blocks with the module cached meta
$this->htmlHeadStrings = array_merge($this->htmlHeadStrings, $content['htmlHeadStrings']);
foreach ($content['metas'] as $type => $value) {
$this->metas[$type] = array_merge($this->metas[$type], $content['metas'][$type]);
}
$xoops->setOption('xoops_pagetitle', $content['xoops_pagetitle']);
$xoops->setOption('xoops_module_header', $content['header']);
}
if ($xoops->getOption('xoops_pagetitle')) {
$this->template->assign('xoops_pagetitle', $xoops->getOption('xoops_pagetitle'));
}
$header = !$xoops->getOption('xoops_module_header') ? $this->template->getTemplateVars('xoops_module_header') : $xoops->getOption('xoops_module_header');
//save meta information of cached pages
if ($this->contentCacheLifetime && $this->contentCacheId && !$contentTpl) {
$content['htmlHeadStrings'] = (array) $this->htmlHeadStrings;
$content['metas'] = (array) $this->metas;
$content['xoops_pagetitle'] = $this->template->getTemplateVars('xoops_pagetitle');
$content['header'] = $header;
$cache->write($this->contentCacheId, $content);
}
// @internal : Lame fix to ensure the metas specified in the xoops config page don't appear twice
$old = array('robots', 'keywords', 'description', 'rating', 'author', 'copyright');
foreach ($this->metas['meta'] as $name => $value) {
if (in_array($name, $old)) {
$this->template->assign("xoops_meta_{$name}", htmlspecialchars($value, ENT_QUOTES));
unset($this->metas['meta'][$name]);
}
}
// We assume no overlap between $GLOBALS['xoopsOption']['xoops_module_header'] and $this->template->getTemplateVars( 'xoops_module_header' ) ?
$this->template->assign('xoops_module_header', $this->renderMetas(true) . "\n" . $header);
if ($canvasTpl) {
$this->canvasTemplate = $canvasTpl;
}
if ($contentTpl) {
$this->contentTemplate = $contentTpl;
}
if (!empty($vars)) {
$this->template->assign($vars);
}
if ($this->contentTemplate) {
$this->content = $this->template->fetch($this->contentTemplate, $this->contentCacheId);
}
if ($this->bufferOutput) {
$this->content .= ob_get_contents();
ob_end_clean();
}
$this->template->assignByRef('xoops_contents', $this->content);
// Do not cache the main (theme.html) template output
$this->template->caching = 0;
$this->template->display($this->path . '/' . $this->canvasTemplate);
$this->renderCount++;
$xoops->events()->triggerEvent('core.theme.render.end', array($this));
return true;
}