Domanda

I am facing an issue regarding change Title on contact page in Magento 2.

I have extend the template

app/design/frontend/Mgs/child_theme_name/Magento_Contact/view/froentend/layout/contact_index_index.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
    <title>Contact Us</title>
</head>
<body>
    <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>

But Doesn,t seem any success.

È stato utile?

Soluzione

Please Check Below Step :-

  1. Go to your Magento store root folder.

  2. You need open the contact_index_index.xml file to edit.

  3. The file is stored under the app\design\frontendMgs\child_theme_name\Magento_Contact\layout folder.

Add This Code In contact_index_index.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <title>Contact Us</title> //Add Your Title Here.
    </head>
    <body>
        <referenceContainer name="content">
            <container name="contact.us.wrapper" htmlClass="row" htmlTag="div" before="-">
                <container name="contact.us.form.wrapper" htmlClass="col-md-6" htmlTag="div" before="-">
                    <block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml">
                        <container name="form.additional.info" label="Form Additional Info"/>
                    </block>
                </container>
                <container name="contact.us.googlemap.wrapper" htmlClass="col-md-6" htmlTag="div" after="contact.us.form.wrapper">
                    <block class="Magento\Framework\View\Element\Template" name="contact.us.googlemap" template="Magento_Contact::map.phtml"/>
                </container>
            </container>
        </referenceContainer>
    </body> </page>

If above code does not work for you then do following.

This is a function under vendor/magento/module-contact/Block/ContactForm.php

It contains the following code:

/**
 * @return $this
 */
protected function _prepareLayout()
{
    $this->pageConfig->getTitle()->set(__('Contact Form'));
    return parent::_prepareLayout();
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top