Thursday, October 17, 2013

Magento: Include Layered Navigation In A CMS Page (Home Page)

This is another popular question. Often you want to show items on a CMS page rather than a regular category page. But you still want to have the layered navigation to filter results like it appears by default with Magento at the category level (when listing products).
To add Magento’s layered navigation to a CMS page where you’re showing items simply edit your CMS page in the admin – under the “Design” tab put this code:

<reference name="left">
    <block type="catalog/layer_view" name="catalog.leftnav" before="-" template="catalog/layer/view.phtml"/>
</reference>

 
That will show the layered navigation at the very top of the left column on your CMS page. Of course make sure your CMS page layout is “2column with left bar” (under “layout” in the “Design” tab).

<reference name="left">
    <block type="catalog/layer_view" name="catalog.leftnav" before="-" template="catalog/layer/view.phtml"/>
</reference>

<reference name="left">
    <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">
<action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
        <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
        <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
        <block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
            <label>Shopping Cart Sidebar Extra Actions</label>
        </block>
    </block>
   
    <block type="poll/activePoll" name="left.poll" after="left.permanent.callout">
        <action method="setPollTemplate"><template>poll/active.phtml</template><type>poll</type></action>
        <action method="setPollTemplate"><template>poll/result.phtml</template><type>results</type></action>
    </block>
</reference>
<reference name="content">
   <block type="catalog/product_new" name="product_new" template="catalog/product/list.phtml">
      <action method="setColumnCount"><column_count>4</column_count></action>
      <action method="setProductsCount"><count>0</count></action>
      <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
         <block type="page/html_pager" name="product_list_toolbar_pager" />
         <action method="setDefaultGridPerPage"><limit>12</limit></action>          
      </block>    
   </block>
</reference>

3 comments:

  1. magento extension developmentwas very helpful in answering alot of questions.Thanks for posting.

    ReplyDelete
  2. Hi. I have a site where we have implemented this, but we are using ajax. The issue is, each ajax call return complete homepage instead of just the block portion. Can you point me in the right direction here?

    ReplyDelete
  3. Thanks for the best blog.it was very useful for me.keep sharing such ideas in the future as well.this was actually what i was looking for,and i am glad to came here!
    magento development company in bangalore 

    ReplyDelete