2

I am working on a Magento 2.1.7 shop and I have created a child-theme of Magento Blank.

I've changed the layout of my homepage to 2 columns with left bar from Content -> Pages. I need to do the same for the Contact Us page.

As can be seen in the image below, I don't have this option for the Contact Us page:

enter image description here

What (XML) file must I edit to achieve this?

1

Contacts US is not a cms page and it is an Module page which is manage from Magento_Contacts module.

So, if you want to changes the layout then you should do some code.

Createcontact_index_index.xml if does not exits at

app/design/frontend/{ThemeVendor}/{Themename}/Magento_Contact/layout/contact_index_index.xml

Then create add below codes for changes the layout

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
 </page>

Here, i have set contact us page layout as 1column

layout="1column" 

you can use

 - layout="2columns-left" if want to changes to 2 columns left



 - layout="2columns-right" if want to changes to 2 columns right



 - layout="3columns" if want to changes to 3 columns
  • This is my question: what file(s) shall I change? – Razvan Zamfir Dec 12 '17 at 10:31
  • So, Do you want to changes page layout for all cms page or Contacts US page? – Amit Bera Dec 12 '17 at 10:33
  • "Contact US" page. – Razvan Zamfir Dec 12 '17 at 10:35
  • Is there a way I can add content from the Magento admin above the contact form? Something like: Address: 914-3472 Quisque Rd, Rome. – Razvan Zamfir Dec 13 '17 at 9:50
  • Create a CMS static block and add this block usin WIDGet – Amit Bera Dec 13 '17 at 10:42
0

Navigate to

app/design/frontend/vendor/theme/Magento_Contact/layout/contact_index_index.xml

find this line

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

and replace with

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

If you want to override this layout file in your custom module, create

app/code/Vendor/Module/view/frontend/layout/contact_index_index.xml

and apply the changes as given above.

Don't forget to use sequence in your custom module's etc/module.xml file

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Vendor_Module">
        <sequence>
            <module name="Magento_Contact"/>
        </sequence>
    </module>
</config>
  • I would like to overwrite the contact_index_index.xml file from the theme. How can I do that? – Razvan Zamfir Dec 12 '17 at 10:38
  • check my updated answer – Dinesh Yadav Dec 12 '17 at 10:42
  • I don't have a custom module. I have a custom theme: app/design/frontend/myCompany/my_theme – Razvan Zamfir Dec 12 '17 at 10:52
  • if you added the answer for theme also – Dinesh Yadav Dec 12 '17 at 10:57
  • create app/design/frontend/myCompany/my_theme/Magento_Contact/layout/contact_index_index.xml and do the changes as given in the answer. – Dinesh Yadav Dec 12 '17 at 10:58
0

To edit contact us page you need to edit the form.phtml listed in \vendor\magento\module-contact\view\frontend\layout\contact_index_index.xml

  • Its not recommended to edit vendor files... – Yasar Arafath Mar 26 at 11:18

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.