1

http://localhost/magento2/module/List/Variable

Here Variable is my dynamic value, which would like to show in Breadcrumb & Title via Layout File.

app\code\Custom\Module\view\frontend\layout\module_list_index.xml

<?xml version="1.0" encoding="UTF-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="page.main.title" display="true">
            <action method="setPageTitle">
                <argument name="title" translate="true" xsi:type="string">e-Trade | List {request var goes here}</argument>
            </action>
        </referenceBlock>
        <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">List</item>
                    <item name="label" xsi:type="string">List</item>
                    <item name="link" xsi:type="string">{request var goes here}</item>
                </argument>
            </action>
        </referenceBlock>
    </body>
</page>     
  • I don't think there's a way to use a variable in xml. It's a static format. – Aaron Allen Sep 20 '16 at 3:48
  • Thanks @AaronAllen. So what will be workaround? – Ankit Shah Sep 20 '16 at 3:49
  • 1
    You should build the logic into the block class. Blocks are where most of the dynamic content should be generated. – Aaron Allen Sep 20 '16 at 3:54

Your Answer

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

Browse other questions tagged or ask your own question.