7

I want to move the breadcrumb block purely using local.xml.

It needs to be moved from its default location to the content block somewhere for me to output.

Usually when moving blocks i would unsetChild and then insert, however, this is making the breadcrumb block appear twice and also its not actually moving it anywhere.

<reference name="root">
    <action method="unsetChild"><name>breadcrumbs</name></action>
    <reference name="content">
        <action method="insert"><child>breadcrumbs</child></action>
    </reference>
</reference>
8

This is a good exercise - a good chance to learn. Because a layout XML move in Magento 1 is really a composite operation (unser from original parent, add to new parent), debugging requires testing both conditions.

The insert is obviously working, as you are seeing the breadcrumbs block twice. That means that the unsetChild call is not working. This is almost always the result of one of two things: incorrect child alias or incorrect parent reference. In your case, it is the latter. This is the result of a custom (non-CE) theme; for example, the enterprise/default theme declares the breadcrumbs block in a core/text_list block named breadcrumbs.container.

Also, reference tags should not be nested. They will work when nested, but given that they operate against the global block list by name, it's not necessary.

|improve this answer|||||
  • 1
    Im not so sure it is as simple as this. I am using magento CE and have created a theme. This theme only inherits from the base CE theme. I have grepped the base layout folder for breadcrumb and the only instance is where it is declared in page.xml as name="breadcrumbs" as="breadcrumbs". Therefore i am referencing the correct block. Also, the unset is working because, if i ommit the insert then the breadcrumbs dissapears. But using the insert inserts it twice. Further, it is not actually putting it inside the content block, but still inside root – Marty Wallace May 11 '13 at 9:35
  • It is also worth noting, that the issue only happens if i insert the block to the 'content' block. I am doing this on a category page and if i insert into the product_list for example, then it works fine. Only an issue with the content block. – Marty Wallace May 11 '13 at 9:41
1

Actually breadcrumbs cannot be moved via XML because it has callout in root templates. For example:

        <div class="main-container col1-layout">
        <div class="main">
            <?php echo $this->getChildHtml('breadcrumbs') ?>
            <div class="col-main">
                <?php echo $this->getChildHtml('global_messages') ?>
                <?php echo $this->getChildHtml('content') ?>
            </div>
        </div>
    </div>
|improve this answer|||||
  • 1
    That shouldn't be a problem, if the child does not exist, $this->getChildHtml() will return an empty string. – Fabian Schmengler Jul 9 '15 at 7:11
0

Try just add it without nested references:

<default>
    <reference name="root">
        <action method="unsetChild"><name>breadcrumbs</name></action>
    </reference>
    <reference name="content">
        <action method="insert"><child>breadcrumbs</child></action>
    </reference>
</default>

or:

<default>
    <reference name="root">
        <action method="unsetChild"><name>breadcrumbs</name></action>
    </reference>
    <reference name="content">
        <block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs" template="page/html/breadcrumbs.phtml" />
    </reference>
</default>

Then call the "breadcrumbs" block in your template file.

|improve this answer|||||
  • No, that makes no difference to the behaviour – Marty Wallace May 12 '13 at 10:10
0

May be the breadcrumbs blcok may have been set to different name or different handler so even if u insert it in default it is not moving . u need to define it in the particular handler

<handler>
    <reference name="root">
        <action method="unsetChild"><name>breadcrumbs</name></action>
    </reference>
    <reference name="content">
        <block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs" template="page/html/breadcrumbs.phtml" />
    </reference>
</handler>
|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.