Banner Image
Banner Image
Banner Image

Magento SetColumnCount Based on layout Selection – PHTML

I was worked lot of project for this layout based columncount on Magento Product listed page. But all time i was used only the XML solution. But that won’t work with multiple layout which is selected by admin on category layout section.

Now i can show the simple method to fix that problem on layout selection.

Go to the list.phtml file on your magento theme file.

There you can commend this line

[php]
$pageLayoutTemplate = $this->getLayout()->getBlock(‘root’)->getTemplate();

switch ($pageLayoutTemplate) {
case ‘page/1column.phtml’:
$_columnCount = 5;
break;

case ‘page/2columns-left.phtml’:
$_columnCount = 4;
break;

case ‘page/2columns-right.phtml’:
$_columnCount = 4;
break;

case ‘page/3columns.phtml’:
$_columnCount = 3;
break;

default:
$_columnCount = 4;
break;
}
[/php]

Blog

27/10/2025
The Rise of Atlas Browser: Why More Users Are Switching to a Privacy-First Web
In today’s digital world, almost everything we do — from searching for information to online…
24/10/2025
Understanding WordPress: A Simple Guide for Beginners in 2025
If you’ve ever wondered how people build websites without knowing how to code, the answer…
15/10/2025
Building a Robust eCommerce Website with Magento: A Complete Guide by Sharesoft
In today’s fast-moving digital world, building a strong online presence is more than just having…
11/10/2025
Why Custom Shopify Website Development Is the Key to Building a Scalable eCommerce Brand
Introduction: The Rise of Shopify in Modern eCommerce In today’s fast-paced digital marketplace, where customer…

Stay Ahead in Digital Innovation

Looking for expert tips, industry insights, and strategies to boost your digital presence? Subscribe to Sharesoft Technology’s weekly LinkedIn newsletter!