Magento – add custom layout template

Current magento version – 1.3.2.4

This is what you need to do to add a new layout template, eg 4 column page layout.

  1. Copy app/code/core/Mage/Page/etc/config.xml
    to app/code/local/Mage/Page/etc/config.xml.
    Creating this new file will allow magento core updates to occure without over-writing your changes (you’ll probably have to look out for changes to the core config.xml to megre them into your custom file).
  2. Register your custom module by adding a new file to app/etc/modules, called something like Mage_Local.xml
  3. In this file add the following code:
    <?xml version="1.0"?>
    <config>
    <modules>
    <Mage_Page> //relates to file structure
    <active>true</active> //set to active
    <codePool>local</codePool> //tell which folder to look in
    <depends> //requires the mage core
    <Mage_Core/>
    </depends>
    </Mage_Page>
    </modules>
    </config>
  4. Now create your new template file, easy way is to copy an existing one such as 3columns.phtml (in app/design/frontend/your_package/your_theme/template/page), and give it a name, such as 4columns.phtml
  5. Register this new template in the config.xml file your created in step 1 by adding your module to the layouts list. For my 4 column example I have added:
    <four_columns module="page" translate="label">
    <label>4 columns</label>
    <template>page/4columns.phtml</template>
    <layout_handle>page_four_columns</layout_handle>
    </four_columns>

You should now be able to access this new template in the cms->manage pages option in the magento admin backend.

  • Share/Bookmark

Related posts:

  1. Magento – url functions
  2. Introduction to Magento
  3. Magento – using jQuery
  4. Magento – changing the root folder after install

10 Responses to “Magento – add custom layout template”

  1. lifeBLUE Blog | Company Insights on Search Marketing and Web Design Says:

    [...] LoonyBlurb – Custom Layout Templates If you work with Magento for very long, you’ll find yourself needing to create custom layout templates. This blog makes that easy to do. [...]

  2. Peter Hinton Says:

    Great post, I have been tearing my hair out over this

  3. Joomla Templates Design and Services Says:

    I am indeed very grateful for receiving such pertinent information from your post. I do expect for
    more essential information for the next post. Keep it up.

  4. Sankho Says:

    Great post! Really helped me out with a project. Thanks!

  5. Hipson Wisely Says:

    Very usefull Info Thank You for sharing

  6. James Says:

    Hi, i’m new to magento but just attempting this now, i have no app/code/local/Mage/Page/etc/ folder just to be sure do i have to create this or should i have this folder already?

    Thanks!

  7. loonytoons Says:

    Hi James,

    if you don’t have an app/code/local/Mage/Page/etc folder then you need to create one.
    Unless you’ve had cause to already modify this section of code then you won’t already have this in the local folder.

    Using this local folder allows us to modify sections of the core code or add to it without worrying that it’ll get overwritten during any core updates.

    Hope that helps!

  8. James Says:

    Thanks for the fast help loonytoons,

    This is now working as expected, helped me out with a project and a deadline!

    Really useful post, thanks again

  9. John Natoli Says:

    Thanks for this post man. I have a problem though. I followed all the steps and copied and pasted the xml exactly as you have it into a file in the modules folder, but now when i click the dropdown in the backend to assign a template, the dropdown is blank. i see //tell which folder to look in, but which folder are you referring to? Thanks!

  10. John Natoli Says:

    nevermind, i figured it out. i can’t figure out how to attached stylesheets and all that via a layout now though. i had been using local.xml, but since switching templates it no longer works.

Leave a Reply