- Web templates
- E-commerce Templates
- CMS & Blog Templates
- Facebook Templates
- Website Builders
Magento. How to change number of columns on search results page
March 7, 2016
This tutorial will show you how to change number of columns on search results page in Magento.
Magento. How to change number of columns on search results page-
Connect to your FTP or access your site files via Cpanel and navigate to app/design/frontend/tm_themes/themexxx/template/tm/productlistgallery, where themexxxx is your theme. In this directory locate list.phtml file. You can edit it in cpanel or download it and edit using any text editor, such as Sublime or Notepad++:
-
In list.phtml file locate the following code (around line 155):
getColumnCount(); ?>
Now replace it with:
getColumnCount(); ?>
It will comment out the default 3 columns layout and enable custom option.
-
Add the following code below the code you just replaced in list.phtml, the code will set 3 column layout for all pages, which are not search results pages, and 4 columns for search results page:
if($this->getRequest()->getControllerName()=='result' || $this->getRequest()->getControllerName()=='advanced') { $col_class='col-sm-3'; } else { $col_class='col-sm-4'; } ?>
Now locate in list.phtml (approximately line 163):
-
And replace col-sm-4 with:
It will load a dynamic class you specified in the “if” statement earlier on this step.
-
After the changes save the file and update it on your server. Now navigate to app/design/frontend/tm_themes/themexxxx/layout/, where themexxxx is your theme. In this directory locate tm_productlistgallery.xml file and start editing it in the same way as the previous file:
On lines 37-57 find the following code:
tm/productlistgallery/list.phtml tm/productlistgallery/list.phtml And replace it with:
tm/productlistgallery/list.phtml 4 tm/productlistgallery/list.phtml 4 It will allow the columns on the search page to be divided in 4 and each contains 4 items.
Now search results will be displayed in 4 columns. You can also clear or disable Magento cache, if the results are still being displayed in 4 columns.
Thank you for checking our tutorial. Now you know how to change number of columns for search results page in Magento.
Feel free to check the detailed video tutorial below:
Magento. How to change number of columns on search results page