doujingya1166 2013-08-29 21:50
浏览 56
已采纳

如何获取Magento中CMS页面当前布局的名称?

Under the design tab of a CMS page in Magento's admin area, there is the option to specify a page layout. I have a few custom fields that I wish to display only on certain page layouts. How can I grab the name of the page layout so I can proceed with an if statement for displaying my custom fields? Thanks in advance!

  • 写回答

2条回答 默认 最新

  • duanche5149 2013-08-30 04:52
    关注
    $root = Mage::app()->getLayout()->getBlock('root');
    
    if ($root) 
    {
        $rootTemplate = $root->getTemplate(); 
    
        switch ($rootTemplate ) 
        {
            case 'page/2column.phtml':
                // Do something.
                break;
    
            //etc.
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?