Magento – Best Practices – Changing Column Count

categorylayoutmagento-1.7theme

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.

Best Answer

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.

Related Topic