How can I change the title of the Contact Page in Magento 2?
-
09-03-2021 - |
Question
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.
Solution
Please Check Below Step :-
Go to your Magento store root folder.
You need open the
contact_index_index.xml
file to edit.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();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange