Magento – Overriding 1 column page layout

layoutmagento2page

This seems like a really basic question, but i want to change the page layout for 1-column pages created in the CMS, how do i do this without changing the layout of the homepage?

To change the homepage i've overriden cms_index_index.xml, and added additional blocks. I want to do the samething for all other 1 column pages, but they need a different wrapper class as follows:

<referenceContainer name="main.content" htmlClass="page-main wrapper">
            <container name="main.content.inner" htmlTag="div" htmlClass="wrapper-inner wrapper-inner--condensed" />
        </referenceContainer>

I'm overriding cms_page_view.xml. Am i overriding the correct file because the above change isn't being picked up?

Best Answer

Yes, cms_page_view.xml is the right file:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content" htmlClass="test">

Make sure that the container you reference is actually on the page.

Related Topic