2

Setting:

  • Using Magento 1.9
  • My Default template is 2column_left set at my local.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:

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?

  • It is possible to do this in the admin, if one does not have many categories. Under Catalog -> Manage -> Categories ->Custom Design Tab -> Page Layout change the layout to 1column. But still looking for a way to do it using local.xml. – bellow Sep 12 '15 at 11:48
  • Take a look at stackoverflow.com/questions/19229441/… – Renon Stewart Sep 12 '15 at 22:33
  • Thanks for that R.S., It was the last piece of the puzzle. – bellow Sep 14 '15 at 0:17
3

Still a noob. There is still a lot to learn. The real answer is understanding the whole concept.

  1. Didn't realize the 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.
  2. IsAnchor=Yes uses the catalog_category_layered whereas IsAnchor=No uses the catalog_category_default XML settings respectively.
  3. Didn't know exactly when and where does the catalog_category_layered_nochildren comes in the process and how it should be implemented.

I finally came to a solution after working backwards.

  1. Since I know that I will use the catalog_category_layered_nochildren handle (and I wasn't able to find something like catalog_category_default_nochildren), I set all my categories to IsAnchor=Yes.
  2. From that, I will not need the extra code for catalog_category_default.

  3. 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 the catalog_category_layered will overwrite it so I keep getting the 2column_left instead of 1column for the categories without subcategories. Realizing the default handle, I set my 2column_left there. My final local.xml

    <default>
      <reference name="root">
        <action method="setTemplate">
          <template>page/2columns-left.phtml</template>
        </action>
      </reference>
    </default>
    
    <catalog_category_layered_nochildren>
      <reference name="root">
        <action method="setTemplate">
          <template>page/1column.phtml</template>
        </action>
      </reference>
    </catalog_category_layered_nochildren>
    

Now all the categories without subcategories will have 1column layout, and all the rest will have 2column_left.

CB

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.