Magento:禁用布局页面模板,如3-columns.phtml等


Magento: Disable Layout Page Templates like 3-columns.phtml and so on

我想只基于两列创建整个网站。所以我想删除所有的一列和三列布局。

我想删除这些选项,甚至从管理领域。

如何做到这一点?

您需要重写(无论是使用app/code/local还是使用模块)Mage_Page_Model_Source_Layout::getOptions(),如下所示:

/**
 * Retrieve page layout options
 *
 * @return array
 */
public function getOptions()
{
    // Array of layout codes that are allowed
    $allowedLayoutCodes = array('empty', 'two_columns_left', 'two_columns_right');
    if ($this->_options === null) {
        $this->_options = array();
        foreach (Mage::getSingleton('page/config')->getPageLayouts() as $layout) {
            // If layoutCode in foreach loop is allowed
            if(in_array($layout->getCode(), $allowedLayoutCodes)) {
                $this->_options[$layout->getCode()] = $layout->getLabel();
                if ($layout->getIsDefault()) {
                    $this->_defaultValue = $layout->getCode();
                }
            }
        }
    }
    return $this->_options;
}

对于从管理区域删除布局选项,您必须编辑核心文件。为此,请在app''code''core''Mage''Page''etc''config.xml中评论所需布局。

请确保已从前端主题中删除所有已删除的布局引用。