本文整理汇总了PHP中XoopsTpl::getTemplateVars方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsTpl::getTemplateVars方法的具体用法?PHP XoopsTpl::getTemplateVars怎么用?PHP XoopsTpl::getTemplateVars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XoopsTpl
的用法示例。
在下文中一共展示了XoopsTpl::getTemplateVars方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test__construct
public function test__construct()
{
$xoops = \Xoops::getInstance();
$this->assertSame('{', $this->object->left_delimiter);
$this->assertSame('}', $this->object->right_delimiter);
$this->assertTrue(in_array(\XoopsBaseConfig::get('themes-path') . DIRECTORY_SEPARATOR, $this->object->getTemplateDir()));
$this->assertSame(\XoopsBaseConfig::get('var-path') . '/caches/smarty_cache' . DIRECTORY_SEPARATOR, $this->object->getCacheDir());
$this->assertSame(\XoopsBaseConfig::get('var-path') . '/caches/smarty_compile' . DIRECTORY_SEPARATOR, $this->object->getCompileDir());
$this->assertSame($xoops->getConfig('theme_fromfile') == 1, $this->object->compile_check);
$this->assertSame(array(\XoopsBaseConfig::get('lib-path') . '/smarty/xoops_plugins' . DIRECTORY_SEPARATOR, SMARTY_DIR . 'plugins' . DS), $this->object->plugins_dir);
$this->assertSame(\XoopsBaseConfig::get('url'), $this->object->getTemplateVars('xoops_url'));
$this->assertSame(\XoopsBaseConfig::get('root-path'), $this->object->getTemplateVars('xoops_rootpath'));
$this->assertSame(\XoopsLocale::getLangCode(), $this->object->getTemplateVars('xoops_langcode'));
$this->assertSame(\XoopsLocale::getCharset(), $this->object->getTemplateVars('xoops_charset'));
$this->assertSame(\Xoops::VERSION, $this->object->getTemplateVars('xoops_version'));
$this->assertSame(\XoopsBaseConfig::get('uploads-url'), $this->object->getTemplateVars('xoops_upload_url'));
}
示例2: 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;
}