.

.

Call Any block Or Extension in any Page in Magento



Here I am  using my left navigation extension in home Page.
I  call Extension block in Home page layout . For Home Page we  will edit in local.xml .
Firstly Find Out the block where we used & call it any layout where you want
Like Our Extension block is this :-
<block type="sidenav/navigation" name="codnitive.home.sidenav.content.top" as="codnitiveSidenavContent" before="slider">
                <action method="setTemplate" modules="codnitivecatalog/sidenav/">
                    <template>codnitive/sidenav/navigation.phtml</template>
                </action>
            </block>


Now we put this block in Home Page . So we have to change in  local.xml
Suppose this is  home  page layout here we add left navigation in index reference & before content & before slider so call it just like this in xml File .
Themename/default/layout/local.xml

local.xml


<cms_index_index>
        <reference name="root">
<block type="sidenav/navigation" name="codnitive-home-side-nav" as="codnitive-home-side-nav" before="slider" template="codnitive/sidenav/navigation.phtml">            
            </block>                                              
               
            <!-- define the block slider -->
            <block type="cms/block" name="slider" as="slider" translate="label" before="content" after="codnitive-home-side-nav">
                <action method="setBlockId"><block_id>home-carousel</block_id></action>
            </block>                                                 
                                                                            
        </reference>                                        
        <reference name="left">
            <block type="catalog/navigation" before="-" name="leftNav" as="leftNav" template="catalog/navigation/leftnav.phtml"/>
        </reference>
        <reference name="content">
            <block type="cms/block" name="home-slider-below-banner" before="-" after="slider">
               <action method="setBlockId"><block_id>home-block-below-slider</block_id></action>
           </block>                                               
                                                                                               
        </reference>
    </cms_index_index>
Now this  navigation block call in .phtml file . Here For Home Page Cms we call 1 column layout.
So we call it in theme name/template/page/html.1column.phtml 
Like this
<?php
// call codinative slider
//call block name
echo $this->getChildHtml('codnitive-home-side-nav');

?>

Latest