2010-12-03 79 views
0

有人试图在代码中更改joomla 1.5模板吗?不知道如何在当前版本上做到这一点。我只是想在用户登录后更改模板。用户在joomla中登录后更改模板1.5

所以,我写这样的代码:

$mainframe->setTemplate('newtemplate'); 

但它没有工作。当我看到joomla application.php,哎呀,那里没有setTemplate函数,但它曾经在1.5之前(基于我在网上的搜索)。 任何人都知道如何做到这一点?

更新: 似乎我们可以设置用户状态,并只读取该用户状态,然后渲染。但我不知道joomla是在哪里渲染模板的,因为我在library/joomla/application.php中放入了一个代码,但是render()却没有被执行。这是我做的:

function render() 
{ 
    $params = array(
     'template'  => $this->getTemplate(), 
     'file'  => 'index.php', 
     'directory' => JPATH_THEMES 
    ); 

    // I added this code, where i set the user state $option.template somewhere else 
    $template = $mainframe->getUserState("$option.template", 'FoxySales01VIP'); 
    if(!empty($template)){ 
     $params['template'] = $template; 
    } 

    $document =& JFactory::getDocument(); 
    $data = $document->render($this->getCfg('caching'), $params); 
    JResponse::setBody($data); 
} 

回答

0

没关系,我解决了它。

只需更改核心库(JDocument类)中的代码以从会话中读取模板,即可正常工作。

谢谢

+0

你在哪里设置?请提供文件位置.. – 2012-01-11 17:39:27