6

I am adding breadcrumb block on layout file contact_index_index.xml but not showing on contact page.

Following code for contact_index_index.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <title>Contact Us</title>
    </head>
    <body>
        <referenceContainer name="content">
             <block class="Magento\Theme\Block\Html\Breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
            <block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml">
                <container name="form.additional.info" label="Form Additional Info"/>
            </block>
        </referenceContainer>
    </body>
</page>

I want to show breadcrumb on contactus page.

3

1 Answer 1

26

Try this code:

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <title>Contact Us</title>
    </head>
    <body>
        <referenceBlock name="breadcrumbs">
            <action method="addCrumb">
                <argument name="crumbName" xsi:type="string">Home</argument>
                <argument name="crumbInfo" xsi:type="array">
                    <item name="title" xsi:type="string">Home</item>
                    <item name="label" xsi:type="string">Home</item>
                    <item name="link" xsi:type="string">{{baseUrl}}</item>
                </argument>
            </action>
            <action method="addCrumb">
                <argument name="crumbName" xsi:type="string">Contact Us</argument>
                <argument name="crumbInfo" xsi:type="array">
                    <item name="title" xsi:type="string">Contact Us</item>
                    <item name="label" xsi:type="string">Contact Us</item>
                </argument>
            </action>
        </referenceBlock>
        <referenceContainer name="content">
            <block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml">
                <container name="form.additional.info" label="Form Additional Info"/>
            </block>
        </referenceContainer>
    </body>
</page>
5
  • Thnks buddy...!!! Mar 15, 2016 at 10:49
  • @Magev2. How can set home page URL/Link as Base URL?
    – Jackson
    Sep 5, 2016 at 3:26
  • @MikeSmith, when you use <item name="link" xsi:type="string">/</item> this will bring you to homepage if you don't use sub folder for your website url. If current, you are developing with sub folder, it will take you wrong link, but i think you will remove sub folder when you live site Sep 6, 2016 at 8:22
  • 2
    @Magev2 got answer by using <item name="link" xsi:type="string">{{baseUrl}}</item>
    – Jackson
    Sep 6, 2016 at 8:25
  • Perfect!! Thx you! In my case, my code must have translate="true" . <action method="addCrumb"> <argument name="crumbName" xsi:type="string" translate="true">Contact Us</argument> <argument name="crumbInfo" xsi:type="array"> <item name="title" xsi:type="string" translate="true">Contact Us</item> <item name="label" xsi:type="string" translate="true">Contact Us</item> </argument> </action> Apr 7, 2020 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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