Pages

Wednesday, July 3, 2013

Add a New Block to a Magento Template

Go to page.xml and below this:

    <block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>

Add your new code (e.g.)

    <block type="page/html_lookbookimage" name="lookbookimage" as="lookbookimage"/>

Now, to to /app/code/local/Mage/Page/Block/Html and create a new file called Lookbookimage.php with this code inside:

    <?php
    class Mage_Page_Block_Html_Lookbookimage extends Mage_Core_Block_Template
    {
    function __construct()
    {
    parent::__construct();
    $this->setTemplate('page/html/lookbookimage.phtml');
    }
    }
    ?>

Now create a file, called lookbookimage.phtml in /app/design/frontend/default/YOUR TEMPLATE/template/page/html/

I assume all three steps are required and the names (highlighted) need to match.

No comments:

Post a Comment