2

So far I know two ways of changing the column count.

Option 1. Hard Coding it:

Change:

<?php $_columnCount = $this->getColumnCount(); ?>

To:

<?php $_columnCount = 4 ?>  //or whatever number you desire

Option 2. Under Manage Categories in the Backend under the Custom Design Tab:

    <reference name="product_list">
        <action method="setColumnCount"><count>4</count></action>
    </reference>

Are both methods equally good? What is the benefit to not hard coding the column count in? I imagine one benefit would be that different categories could get different column counts.

Is there a better way? Is there anything I am missing? They both seem pretty hard coded to me.

3 Answers 3

1

There is a use case for both.

If a template is designed around a specific number of columns, with no fluidity, that would break should the column count be changed; then making it inaccessible to the store operator (ie. putting it in a phtml file) would prevent problems.

Similarly, if the template was fluid, and could happily tolerate being changed - then let it be defined somewhere within reach of the store operator.

We prefer to define this within XML files, to keep phtml files clean of setting declaration, and keep it out of reach of store operators.

1
1

Using the second method (the layout update XML in the Custom Design tab) is more flexible - it's easier to edit that field than to edit .phtml files. It can be easier for store admin who may have no experience in Magento's PHP/HTML mix in .phtml templates.

The same XML code you can use in the XML files, such as local.xml of your theme.

1

If you want to change layout of category column then its best practice to put layout handle call in category layout update area, so admin can easily change layout for any category.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.