0

I want to add a title to a block with nothing more than layout xml, is there a generic class or block that I can use for this?

I've just tried page.title.main's class and template but it is too big and you can't pass a parameter for which html heading tag to use. Is there another? I cannot find it in the framework folder either.

    <block class="MyDesiredMAGENTOClass" name="account.navigation.title" template="html/title.phtml">
        <arguments>
            <argument name="css_class" xsi:type="string">test</argument>
            <argument name="tag" xsi:type="string">h#</argument>
            ...
            ...
        </arguments>
    </block>
1

In the same layout.xml you can set the page title, here it is an example, in the head you set the title of the page, and in the block setPageTitle you set the title for the page. Hope it helps!

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="customer_account"/>
    <head>
        <title>My Title</title>
    </head>
    <body>
        <referenceBlock name="page.main.title">
            <action method="setPageTitle">
                <argument translate="true" name="title" xsi:type="string">My Title</argument>
            </action>
        </referenceBlock>
        <referenceContainer name="content">
            <!--Your content-->
        </referenceContainer>
    </body>
</page>
  • I don't want to set the page title. – LM_Fielding Dec 15 '16 at 15:47

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.