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

11/12/2025
The Complete Beginner’s Guide to AI SEO in 2025: How Artificial Intelligence Is Changing Search Ranking Forever
If you’ve ever tried to grow a website, get more traffic, or rank on Google,…
25/11/2025
How Google’s New AI Shopping Revolution Makes Online Buying Easier — And What It Means for Your Business
Introduction The holiday shopping season is here — and Google is making it smarter. With…
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…
Bulb

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!