0

So, I'm trying to update the product list page to my own custom layout inside of Magento 2.

Files I've made inside of my theme are as follows:

/app/design/frontend/Theme/default/Magento_Catalog/layout/catalog_category_view.xml

and I've created the following:

/app/design/frontend/Theme/default/Magento_Theme/page_layout/2columns-cat.xml

Inside of my catalog_category_view.xml, which i know is the correct handle i've added the following:

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

I know its using this handle, because i can cause an error by editing this xml file.

I have also updated and added it into the * layouts.xml* like so:

<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
<layout id="2columns-cat">
    <label translate="true">2 Column left Cat</label>
</layout>

And here is my 2columns-cat xml:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-cat" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <move element="page.main.title" destination="content" before="-"/>
    </body>
</page>

But it isn't updating the layout. It remains a 2column-left and doesn't use the 2column-cat. Am i doing something wrong? All caches are flushed - cleared the gen folder - cleared the cache folder, nothing.

Can't think of what might not be causing the layout change.

0

Have you declared your custom layout in <theme_dir>/<Namespace>_<Module>/layouts.xml?

Example:

<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
    <layout id="2columns-cat">
        <label translate="true">2 Columns Category Page</label>
    </layout>
</page_layouts>

There are more examples on this dev docs page.

  • Yes sorry did this as well. – andy jones Apr 6 '18 at 10:40
  • Hmm in that case I'm not sure. Can you add the contents of your page layout plz? And is there anything in your logs? – Ben Crook Apr 6 '18 at 10:42
  • Nothing in logs. I can't even change the layout to a 1column either. – andy jones Apr 6 '18 at 10:42
  • @andyjones Try removing <body>, I don't think it's allowed inside page layouts. Also try adding <update handle="2columns-left"/> and see if that makes a difference. I feel like it's ignoring your layout due to an error that isn't logged any where. – Ben Crook Apr 6 '18 at 10:55
  • nope, removing body didn't work, and update handle simply rendered a blank page. Stupid thing!! >:( what makes me think it isn't me, is that i can't even change it to 2 column-right – andy jones Apr 6 '18 at 11:02

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.