1

Consider I have a custom theme called MyTheme1 in default design package.

I want to create different page layouts ( like 1column, 2column, 3column ) for this specific theme. So if theme selected by the user in system configuration, then page layouts appears in different parts in magento, so that user can choose between them wherever he wants.

I've also another theme called MyTheme2 with different page layouts ( 1column, 3column and 5column). If user changed the theme to MyTheme2, I want the Page Layout drop down filled with those page layouts.

How can I accomplish this ?

I know I can create a module Mage_Page and edit config.xml and add my desired page layouts, but it adds for all themes. I want theme-specific page layouts. Is it possible in magento ? How can I have different page layouts for different themes in magento ?

Can you please help me?

1 Answer 1

2

We have three source models to select a page layout from:

  • Catalog_category has a source_model: catalog/category_attribute_source_layout
  • the products another: catalog/product_attribute_source_layout

but they both get their options from the third Mage_Page_Model_Source_Layout (page/source_layout) which is used:

public function getAllOptions()
{
    if (!$this->_options) {
        $this->_options = Mage::getSingleton('page/source_layout')->toOptionArray();

So depending on where you want to change the source, you can change the category model, the product model or the page model to change them all.

I thought about your own model, rewriting the page/source_layout model to add the filtering.

Last question is, where do one save the mapping between layout and theme. At least not in the config.xml with the layouts, because it is hard to transport additional config-settings through \Mage_Page_Model_Config::_appendPageLayouts to \Mage_Page_Model_Source_Layout::getOptions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.