0

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.

3

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();
}
  • Thanks for your response. I have extended as you suggested and clear all the cache but still no success. – Urocks Aug 13 at 6:12
  • check updated answer. – Rk Rathod Aug 13 at 6:25
  • Thanks For quickly response but still no success. I have search the title of contact page in my folder it found on vendor/magento/module-customer/Block/Form/Register.php If i change it from there it will updated on register page also The function which do this protected function _prepareLayout() { $this->pageConfig->getTitle()->set(__('Create New Customer Account')); return parent::_prepareLayout(); } – Urocks Aug 13 at 6:47
  • zemez.io/magento/support/how-to/… check this – Rk Rathod Aug 13 at 6:50
  • check my updated answer – Rk Rathod Aug 13 at 6:52

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.