Magento – Breadcrumb on custom category listing page Magento 1.9

breadcrumbscustommagento-1.9

I am working on a theme which is customized by someone else.

So in

/websitename.com/app/design/frontend/rwd/ysv/template/page/category.phtml

is created which is called.When I click on any category or subcategory.

I want to show breadcrumbs, when user is on category/sub-category page.

echo $this->getLayout()->getBlock('breadcrumbs')->toHtml();
This will not help in my case i think.

System > Configuration > General > Web > Default Pages > Show Breadcrumbs for CMS Pages. is set to YES.

Update:

<catalog_category_default translate="label">
        <label>Catalog Category (Non-Anchor)</label>
    .........
     <reference name="content">
            <block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
                <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
                <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
                <block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>         <!-- Addedd -->

and

    <catalog_category_layered translate="label">
        <label>Catalog Category (Anchor)</label>
      .....................
        <reference name="content">
            <block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
                <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
                    <block type="core/text_list" name="product_list.name.after" as="name.after" />
                    <block type="core/text_list" name="product_list.after" as="after" />
                    <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
                        <block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>     <!-- Addedd -->      

In page.xml

<!-- category (default) -->
    <catalog_category_default>
    <reference name="root">
      <action method="setTemplate"><template>page/category.phtml</template></action>
    </reference>
    </catalog_category_default>

In category.phtml

<?php echo $this->getChildHtml('head'); ?>
<?php echo $this->getChildHtml('after_body_start'); ?>

<!-- global messages -->
<?php echo $this->getChildHtml('global_notices'); ?>

<!-- header -->
<?php echo $this->getChildHtml('header'); ?>

<!-- content -->
<?php echo $this->getChildHtml('content'); ?>

<!-- footer -->
<?php echo $this->getChildHtml('footer'); ?>
<?php echo $this->getChildHtml('before_body_end'); ?>
<?php echo $this->getAbsoluteFooter(); ?>

Can I create dynamic breadcrumbs based on current URL in a custom module or any other method? Please suggest.

Best Answer

You can add breadcrumbs to your custom page using xml. Add following xml code in your theme's local.xml file.

<module_controller_action translate="label">
   <reference name="breadcrumbs"> 
      <action method="addCrumb"> <!--add breadcrumb-->
         <name>home</name>
           <params> 
             <label>Home</label> 
             <title>Home</title> 
             <link>/</link> 
           </params> 
      </action>
      <action method="addCrumb"> <!--add breadcrumb-->
         <name>custompage</name>
           <params> 
             <label>custompage</label> 
             <title>custompage</title> 
             <link>/custom/page/link</link> 
           </params> 
      </action> 
   </reference>
</module_controller_action>