0

I have created a page http://www.extenderstore.com.au/shipping.html and I would like to change the layout to 2 columns with left bar. I made a file in Magento_Catalog/layout/ called catalog_category_view.xml with the code:

<?xml version="1.0" encoding="utf-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head></head>
<body></body>

But it's not working?

  • is it a category or cms page? – Piyush Oct 2 '17 at 8:06
  • it is a category page – bondimedical Oct 2 '17 at 8:10
1

You can change layout of category from admin, follow below steps-

  1. Go To Products -> Categories
  2. Select your Category, for which you want to change layout.
  3. Select Design tab
  4. uncheck Use Parent Category Settings, if checked
  5. from layout select 2columns-left and save category

Update:- if you check the Luma theme's layout for category view page at path-

/your_magento/vendor/magento/module-catalog/view/frontend/layout/catalog_category_view.xml`

you can see that category description block category.description and static block content category.cms are added under <referenceContainer name="columns.top">

So you if you want to add them under main content you have to override catalog_category_view.xml to move both those block under <referenceContainer name="content">

you can add below code in your layout to move them to the content block

<move element="category.description" destination="content" as="category_description" />
<move element="category.cms" destination="content" after="category_description" />
  • I have tried that and it doesn't work – bondimedical Oct 2 '17 at 8:18
  • did you run setup:upgrade command after applying chnages? – Piyush Oct 2 '17 at 8:20
  • yes I did. I do so for all theme changes – bondimedical Oct 2 '17 at 8:23
  • I visited the url you mentioned it is 2columns-left layout, as your <body> tag has class page-layout-2columns-left – Piyush Oct 2 '17 at 8:27
  • So why is the text 1 column? – bondimedical Oct 2 '17 at 8:30
2
<?xml version="1.0"?>
   <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
       <body>
       </body>
    </page>

Should be enough, have you cleared your cache after your change? You can also try clearing var/* and pub/static followed by a php bin/magento setup:static-content:deploy

  • I have done all those things but the text I enter in the "Content" tab of the category is still one column – bondimedical Oct 2 '17 at 7:52
1

There are two ways to set up your layout for category page

  1. From admin panel for specific category.
  2. With code for setting a parent layout of to be followed from all the categories.

Here is the way to set the layout

From admin panel for specific category.

 1. go to admin panel
 2. Products > categories
 3. Select the category for which you want to set the layout as you wanted
 4. Design > Layout >Select the desired Layout
 5. Save the Category.

With code for setting a parent layout of to be followed from all the categories.(Recommended)

  1. Create a directory structure in your own theme as

    app\design\frontend\Vendor\Module\Magento_catalog\layout

  2. create a file there with name catalog_category_view.xml

  3. Put this code into the file

    <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="content"> <block class="Magento\Theme\Block\Html\Title" name="page.main.title" template="html/title.phtml"/> </referenceContainer> <move element="category.description" destination="content" after="page.main.title"/> </body> </page>

  4. Run this command

    php bin/magento cache:clean

  5. Refresh your that category page

  • I have done this. How can I add a block now with content which is in the second column? – bondimedical Oct 2 '17 at 8:56
  • 1
    your layout is already in the following the 2columns-left layout just simply put this <move element="category.description" destination="content" after="page.main.title"/> code between the reference container than you will be able to see the effect. – Abhishek Tripathi Oct 2 '17 at 9:10
  • you can simply add a product also to see the page layout of your category page – Abhishek Tripathi Oct 2 '17 at 9:20

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.