Question

Right Now I'm facing issue to set base url in magento CMS page layout. Right now I'm doing like this,but I am not getting base url :

<action method="addCrumb">
    <crumbName>Home</crumbName>
    <crumbInfo>
        <label>Home</label>
        <title>Home</title>
        <link> {{store url}} </link>
    </crumbInfo>
</action>
Was it helpful?

Solution

You are probably using the wrong reference. Only the Mage_Page_Block_Html_Breadcrumbs class has theaddCrumb method. Example:

<reference name="breadcrumbs">
    <action method="addCrumb">
        <crumbName>Home</crumbName>
        <crumbInfo>
            <label>Home</label>
            <title>Home</title>
            <link>/</link>
        </crumbInfo>
    </action>
    <action method="addCrumb">
        <crumbName>CMS Page</crumbName>
        <crumbInfo>
            <label>CMS Label Page</label>
            <title>CMS Title Page</title>
        </crumbInfo>
    </action>
</reference>

EDIT:

To get dinamic info to new crumb added, rewrite Mage_Page_Block_Html_Breadcrumbs. The crumbs are storage into array like this:

/**
 * Array of breadcrumbs
 *
 * array(
 *  [$index] => array(
 *         ['label']
 *         ['title']
 *         ['link']
 *         ['first']
 *         ['last']
 *     )
 * )
 *
 * @var array
 */

Creating the addCrumbCms method:

function addCrumbCms($crumbName, $crumbInfo, $after = false)
{
    $crumbInfo['link'] = Mage::getUrl() . Mage::getSingleton('cms/page')->getIdentifier();

    $this->_prepareArray($crumbInfo, array('label', 'title', 'link', 'first', 'last', 'readonly'));
    if ((!isset($this->_crumbs[$crumbName])) || (!$this->_crumbs[$crumbName]['readonly'])) {
       $this->_crumbs[$crumbName] = $crumbInfo;
    }
    return $this;
}

And use the new method in last crumb, like it:

<reference name="breadcrumbs">
    <action method="addCrumb">
        <crumbName>Home</crumbName>
        <crumbInfo>
            <label>Home</label>
            <title>Home</title>
            <link>/</link>
        </crumbInfo>
    </action>
    <action method="addCrumbCms">
        <crumbName>CMS Page</crumbName>
        <crumbInfo>
            <label>CMS Label Page</label>
            <title>CMS Title Page</title>
        </crumbInfo>
    </action>
</reference>

Note: Create a extension to do it, don't change the core.

OTHER TIPS

I have tried like this:

<reference name="root">
        <action method="unsetChild"><alias>breadcrumbs</alias></action>
        <block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs">
            <action method="addCrumb">
                <crumbName>Home</crumbName>
                <crumbInfo>
                    <label>Home</label>
                    <title>Home</title>
                    <link>/</link>
                </crumbInfo>
            </action>
            <action method="addCrumb">
                <crumbName>Recipes</crumbName>
                <crumbInfo>
                    <label>Recipes</label>
                    <title>Recipe Home Page</title>
                    <link>magenshop/recipe</link>
                </crumbInfo>
            </action>
            <action method="addCrumb">
                <crumbName>Current Page</crumbName>
                <crumbInfo>
                    <label>Current Page</label>
                    <title>Current Page</title>
                </crumbInfo>
            </action>
        </block>
    </reference>

But my / in for my Home, takes me to project root folder, not magento home page.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top