1

I have created a new template for a custom Page Layout to apply to the top-level categories only, using a custom module.

Here is my module/etc/config.xml file from the module (I am not posting the template or the /etc/module/xml file as I don't believe they are relevant. Let me know if you'd like to see them and I will edit):

<?xml version="1.0"?>
<config>
    <modules>
        <Action_ToplevelcatLayout>
            <version>0.0.1</version>
        </Action_ToplevelcatLayout>
    </modules>
    <global>
        <page>
            <layouts>
                <top_level_category_layout_name translate="label">
                    <label>New Top Level Category Layout</label>
                    <template>page/top-level-category-layout.phtml</template>
                    <layout_handle>top-level-category-layout</layout_handle>
                </top_level_category_layout_name>
            </layouts>
        </page>
    </global>
</config>

I assigned this new page layout to all of the top level categories one by one by changing the option selected in the Page Layout dropdown of the Custom Design tab to the new page template - and that works great...but it seems to work too great actually.

The problem I'm having is the subcategories are also inheriting this new Page Layout, which is have only been assigned to it's parent. Use Parent Category Settings on subcategories are set to No.

I can resolve this issue by saving the child categories. If I save them (even without making any changes) the default page template is then reapplied to the subcategories and then work as expected.

Have I done something incorrect here or am I missing something? Why are the subcategories inheriting the parent category page template if it has not been assigned to it? I have also assigned the default template in the local.xml file:

<catalog_category_layered> 
    <reference name="root">
        <action method="setTemplate">
            <template>page/2columns-left.phtml</template>
        </action>
    </reference>
</catalog_category_layered>

<catalog_category_default> 
    <reference name="root">
        <action method="setTemplate">
            <template>page/2columns-left.phtml</template>
        </action>
    </reference>
</catalog_category_default>

If this is what I have to work with, how can I iterate through all of the categories and resave them safely without having to do so manually? I have hundreds of second level categories and really hope to avoid having to manually resave them. Thanks for your help!

UPDATE:

If I disable Use Flat Catalog Category, then both the top-level and subcategories use the correct Page Layout template. How can I ensure that the subcategories use the correct Page Layout template when Use Flat Catalog Category is also enabled? Is there an attribute that I need to modify?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.