2

Every answer I can find for setting the page title (H1 tag not the tab title) uses this format:

<action method="setPageTitle">
    <argument translate="true" name="title" xsi:type="string">Title goes here</argument>
</action>

As the action tag has been deprecated I don't want to use this.

When I try the below method it is ignored.

<arguments>
    <argument translate="true" name="title" xsi:type="string">Title goes here</argument>
</arguments>

How do I achieve the same result using <arguments>?

Does Magento really force us to use deprecated tags to achieve this?

0

The directive is marked as deprecated because Magento wants to stop using imperative directives (xml order what to do) and switch to using declarative (xml declare value but it's up to program to use it) layout directives instead.

This parameter is called "Content Heading" and is set in

AdminOffice->Content->Elements->Pages->Action->Edit->Content->ContentHeading

And PHTML

/var/www/html/m/vendor/magento/module-theme/view/frontend/templates/html/title.phtml

get it like this

escapeHtml($block->getPageHeading())

out of PHP class

/var/www/html/m/vendor/magento/module-theme/view/frontend/templates/html/title.phtml

Since Magento uses declarative layout directives there is no way to force PHP to use xml argument.

---------------------------------------------------
Example how to impose xml attribute

in

AdminOffice->Content->Elements->Pages->Action->Edit->Design->Layout Update XML

copy/past

<referenceContainer name="columns.top">
    <referenceBlock name="page.main.title">
        <arguments>
            <argument name="title" xsi:type="string">Title goes here</argument>
        </arguments>
    </referenceBlock>
</referenceContainer>

in (don't just overwrite original file, extend it in your theme)

/var/www/html/m/vendor/magento/module-theme/view/frontend/templates/html/title.phtml

update variable $title to use our XML value

$blockTitle = $this->getTitle();
if ($blockTitle){
    $title = $blockTitle;
}

Save and clean cache

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.