3

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>
4

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.

| improve this answer | |
  • 1
    my problem is with the base url not breadcrumb. my breadcrumb display absolutely fine but issue with the base url – Murtuza Zabuawala Jan 16 '16 at 10:28
  • Did you try use <link>/</link> to home and path key to pages (equal url path used in cms page form edit)? – Denis Spalenza Jan 16 '16 at 10:34
  • yes i tried it , but in the <link> tag I want to show baseUrl/myCmsPage. – Murtuza Zabuawala Jan 18 '16 at 5:13
  • Answer edited. Now I think you'll get it. – Denis Spalenza Jan 18 '16 at 7:04
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.