Suman KC
Suman KC

Reputation: 3528

How link a menu group in magento (via blocks/.phtml files)

I have created a mega menu group. but i stuck at relating it to file.

All i can see form a default one is

<block type="core/text_list" name="megamenu_left" as="megamenu_left" translate="label">
   <label>Left Megamenu</label>
</block>

In Home page(Backend > Design Section):

<reference name="megamenu_left">
    <block type="megamenu/list" name="megamenu.list.theme" as="megaMenuLeft" template="sm/megamenu/megamenu-left.phtml">
        <action method="setConfig">
            <values>  
                <group_id>2</group_id>
                <theme>2</theme>
            </values>
        </action>
    </block>
</reference>

And in home page Front view:

<?php echo $this->getChildHtml('megamenu_left') ?>

Things i didn't get is name="megamenu.list.theme" and how this is rendering.

EDITED

how is 'megamenu_left' from xml above is linked with a menu group i created on the backend. The menu group i created on backend just have a name and 'enable/disable' option.

Upvotes: 0

Views: 793

Answers (1)

Christoffer Bubach
Christoffer Bubach

Reputation: 1686

I'm not sure if I understand the question correctly, but the second XML bit is going to look for the reference "megamenu_left" found in the first XML part, and insert the block at that position.

The block itself has the full name "megamenu.list.theme" in the layout, with the optional shortname "megaMenuLeft". It will render the template file "sm/megamenu/megamenu-left.phtml" which will be positioned in the active theme folder such as "app/design/frontend/theme/..".

The template will be using the PHP block from module "megamenu/Block/List.php" so any $this->functionName() calls or variables accessed from within the function comes from that block.

The frontpage will load the block by name from the first part of XML, which in turn will get the content from the second part XML since it's a reference, meaning it will insert itself in the first XML.

Upvotes: 1

Related Questions