Setting:
- Using Magento 1.9
- My Default template is
2column_left
set at mylocal.xml
(as shown below)
My categories are as follows and isAnchor=No
:
Top1
Sub1-Top1
Sub1-Sub1-Top1
Sub2-Top1
Sub3-Top1
Sub1-Sub3-Top1
Top2
Sub1-Top2
Sub2-Top2
Sub1-Sub2-Top2
Scenario:
I would like the layout for Sub2-Top1 and Sub1-Top2 (no subcategories) to have the 1column
template and the rest should have the 2column_left
. But I cannot seem to get it correctly.
I was trying to accomplish this task from the examples:
- layout – call left column block within main column (in the 1column.phtml template)
- and https://stackoverflow.com/questions/9763350/how-to-change-the-page-layout-in-magento
local.xml
<ep_catalog_category_template>
<reference name="root">
<action method="setTemplate">
<template>page/2columns-left.phtml</template>
</action>
</reference>
</ep_catalog_category_template>
<ep_no_catalog_category_template>
<reference name="category.products">
<action method="setTemplate">
<template>page/1column.phtml</template>
</action>
</reference>
</ep_no_catalog_category_template>
<catalog_category_layered>
<update handle="ep_catalog_category_template" />
</catalog_category_layered>
<catalog_category_default>
<update handle="ep_catalog_category_template" />
</catalog_category_default>
<catalog_category_layered_nochildren>
<reference name="category.products">
<action method="setTemplate">
<template>page/1column.phtml</template>
</action>
</reference>
</catalog_category_layered_nochildren>
The catalog_category_layered_nochildren
tag should replace the default template to 1column
but it is not working. Instead the output page is 2column
with the left side contains no content and the main content has the list of products. I would like the list of products to use all the page — thus removing the left_column
ergo 1column
. Can it be done using local.xml
? or better yet, how can I do this?
Best Answer
Still a noob. There is still a lot to learn. The real answer is understanding the whole concept.
IsAnchor
Option for the categories.IsAnchor
provides the filters on the left column, and this I need for all the category page which has subcategories.IsAnchor=Yes
uses thecatalog_category_layered
whereasIsAnchor=No
uses thecatalog_category_default
XML settings respectively.catalog_category_layered_nochildren
comes in the process and how it should be implemented.I finally came to a solution after working backwards.
catalog_category_layered_nochildren
handle (and I wasn't able to find something likecatalog_category_default_nochildren
), I set all my categories toIsAnchor=Yes
.From that, I will not need the extra code for
catalog_category_default
.The sequence of the layout handles as pointed out by R.S., https://stackoverflow.com/questions/19229441/magento-find-a-layout-handle-for-product-category-page made it impossible for me to make the
catalog_category_layered_nochildren
execute correctly since thecatalog_category_layered
will overwrite it so I keep getting the2column_left
instead of1column
for the categories without subcategories. Realizing thedefault
handle, I set my2column_left
there. My finallocal.xml
Now all the categories without subcategories will have
1column
layout, and all the rest will have2column_left
.CB