{"id":65690,"date":"2016-03-07T04:57:49","date_gmt":"2016-03-07T09:57:49","guid":{"rendered":"http:\/\/www.templatemonster.com\/help\/?p=65690"},"modified":"2016-04-12T03:51:22","modified_gmt":"2016-04-12T07:51:22","slug":"magento-how-to-change-number-of-columns-on-search-results-page","status":"publish","type":"post","link":"https:\/\/www.templatemonster.com\/help\/magento-how-to-change-number-of-columns-on-search-results-page.html","title":{"rendered":"Magento. How to change number of columns on search results page"},"content":{"rendered":"<p>This tutorial will show you how to change number of columns on search results page in Magento.<\/p>\r\n\r\n<a href=\"http:\/\/www.youtube.com\/watch?v=WmlTltX0Rd0?width=1280&amp;height=720\" rel=\"prettyPhoto\">Magento. How to change number of columns on search results page<\/a><ol>\r\n\t<li>\r\n\t\t<p> Connect to your FTP or access your site files via Cpanel and navigate to <strong>app\/design\/frontend\/tm_themes\/themexxx\/template\/tm\/productlistgallery<\/strong>, where themexxxx is your theme. In this directory locate <strong>list.phtml<\/strong> file. You can edit it in cpanel or download it and edit using any text editor, such as Sublime or Notepad++:<\/p>\r\n\t\t\r\n<a href=\"\/help\/wp-content\/uploads\/2016\/03\/Magento.-How-to-change-number-of-columns-for-search-results-page-1.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2016\/03\/Magento.-How-to-change-number-of-columns-for-search-results-page-1-300x169.jpg\" alt=\"Magento. How to change number of columns for search results page-1\" width=\"300\" height=\"169\" class=\"aligncenter size-medium wp-image-65691\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2016\/03\/Magento.-How-to-change-number-of-columns-for-search-results-page-1-300x169.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2016\/03\/Magento.-How-to-change-number-of-columns-for-search-results-page-1-150x84.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2016\/03\/Magento.-How-to-change-number-of-columns-for-search-results-page-1.jpg 1000w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>\r\n\t<\/li>\r\n\t<li>\r\n\t\t<p>In <strong>list.phtml<\/strong> file locate the following code (around line 155):<\/p>\r\n\t\t<pre class=\"brush:php\">&lt;?php \/\/$_columnCount = $this-&gt;getColumnCount(); ?&gt;\r\n&lt;?php $_columnCount = 3; ?&gt;<\/pre>\r\n\t\t<p>Now replace it with:<\/p>\r\n\t\t<pre class=\"brush:php\">&lt;?php $_columnCount = $this-&gt;getColumnCount(); ?&gt;\r\n&lt;?php \/\/$_columnCount = 3; ?&gt;<\/pre>\r\n\t\t<p>It will comment out the default 3 columns layout and enable custom option.<\/p>\r\n\t<\/li>\r\n\t<li>\r\n\t\t<p>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:<\/p>\r\n\t\t<pre class=\"brush:php\">&lt;?\r\nif($this-&gt;getRequest()-&gt;getControllerName()=='result' || $this-&gt;getRequest()-&gt;getControllerName()=='advanced') {\r\n\t$col_class='col-sm-3';\r\n\t} else {\r\n\t$col_class='col-sm-4';\r\n}\r\n?&gt;<\/pre>\r\n\t\t<p>Now locate in list.phtml (approximately line 163):<\/p>\r\n\t\t<pre class=\"brush:php\">&lt;li class=\"item&lt;?php if(($i-1)%$_columnCount==0): ?&gt; first&lt;?php elseif($i%$_columnCount==0): ?&gt; last&lt;?php endif; ?&gt; col-xs-12 col-sm-4\" itemscope itemtype=\"http:\/\/schema.org\/product\"&gt;<\/pre>\r\n\t\t<p>And replace <strong>col-sm-4<\/strong> with:<\/p>\r\n\t\t<pre class=\"brush:php\">&lt;?php echo $col_class; ?&gt;<\/pre>\r\n\t\t<p>It will load a dynamic class you specified in the &#8220;if&#8221; statement earlier on this step.<\/p>\r\n\t<\/li>\r\n\t<li>\r\n\t\t<p> After the changes save the file and update it on your server. Now navigate to <strong>app\/design\/frontend\/tm_themes\/themexxxx\/layout\/<\/strong>, where themexxxx is your theme. In this directory locate <strong>tm_productlistgallery.xml<\/strong> file and start editing it in the same way as the previous file:<\/p>\r\n\t\r\n<a href=\"\/help\/wp-content\/uploads\/2016\/03\/Magento.-How-to-change-number-of-columns-for-search-results-page-2.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2016\/03\/Magento.-How-to-change-number-of-columns-for-search-results-page-2-300x169.jpg\" alt=\"Magento. How to change number of columns for search results page-2\" width=\"300\" height=\"169\" class=\"aligncenter size-medium wp-image-65692\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2016\/03\/Magento.-How-to-change-number-of-columns-for-search-results-page-2-300x169.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2016\/03\/Magento.-How-to-change-number-of-columns-for-search-results-page-2-150x84.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2016\/03\/Magento.-How-to-change-number-of-columns-for-search-results-page-2.jpg 1000w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a> \r\n\t\t<p>On lines 37-57 find the following code:<\/p>\r\n\t\t<pre class=\"brush:xml\">&lt;catalogsearch_result_index translate=\"label\"&gt;\r\n\t&lt;reference name=\"content\"&gt;\r\n\t\t&lt;reference name=\"search_result_list\"&gt;\r\n\t\t\t&lt;action method=\"setTemplate\"&gt;\r\n\t\t\t&lt;template&gt;tm\/productlistgallery\/list.phtml&lt;\/template&gt;\r\n\t\t\t&lt;\/action&gt;\r\n\t\t&lt;\/reference&gt;\r\n\t&lt;\/reference&gt;\r\n&lt;\/catalogsearch_result_index&gt;\r\n&lt;catalogsearch_advanced_result translate=\"label\"&gt;\r\n\t&lt;reference name=\"content\"&gt;\r\n\t\t&lt;reference name=\"search_result_list\"&gt;\r\n\t\t\t&lt;action method=\"setTemplate\"&gt;\r\n\t\t\t&lt;template&gt;tm\/productlistgallery\/list.phtml&lt;\/template&gt;\r\n\r\n\t\t\t&lt;\/action&gt;\r\n\t\t&lt;\/reference&gt;\r\n\r\n\r\n\t&lt;\/reference&gt;\r\n&lt;\/catalogsearch_advanced_result&gt;<\/pre>\r\n\t\t<p>And replace it with:<\/p>\r\n\t\t<pre class=\"brush:xml\">&lt;catalogsearch_result_index translate=\"label\"&gt;\r\n\t&lt;reference name=\"content\"&gt;\r\n\t\t&lt;reference name=\"search_result_list\"&gt;\r\n\t\t\t&lt;action method=\"setTemplate\"&gt;\r\n\t\t\t&lt;template&gt;tm\/productlistgallery\/list.phtml&lt;\/template&gt;\r\n\t\t\t&lt;\/action&gt;\r\n\t\t\t&lt;action method=\"setColumnCount\"&gt;&lt;columns&gt;4&lt;\/columns&gt;&lt;\/action&gt;\r\n\t\t&lt;\/reference&gt;\r\n\t&lt;\/reference&gt;\r\n&lt;\/catalogsearch_result_index&gt;\r\n&lt;catalogsearch_advanced_result translate=\"label\"&gt;\r\n\t&lt;reference name=\"content\"&gt;\r\n\t\t&lt;reference name=\"search_result_list\"&gt;\r\n\t\t\t&lt;action method=\"setTemplate\"&gt;\r\n\t\t\t&lt;template&gt;tm\/productlistgallery\/list.phtml&lt;\/template&gt;\r\n\t\t\t&lt;\/action&gt;\r\n\t\t\t&lt;action method=\"setColumnCount\"&gt;&lt;columns&gt;4&lt;\/columns&gt;&lt;\/action&gt;\r\n\t\t&lt;\/reference&gt;\r\n\t&lt;\/reference&gt;\r\n&lt;\/catalogsearch_advanced_result&gt;<\/pre>\r\n\t\t<p>It will allow the columns on the search page to be divided in 4 and each contains 4 items.<\/p>\r\n\t<\/li>\r\n\t<li><p>\r\n\t\tNow 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.\r\n\t<\/p><\/li>\r\n<\/ol>\r\n<p>Thank you for checking our tutorial. Now you know how to change number of columns for search results page in Magento.<\/p>\r\n\r\n<p>Feel free to check the detailed video tutorial below:<\/p>\r\n\r\n<a href=\"http:\/\/www.youtube.com\/watch?v=WmlTltX0Rd0?width=1280&amp;height=720\" rel=\"prettyPhoto\">Magento. How to change number of columns on search results page<\/a>","protected":false},"excerpt":{"rendered":"<p>This tutorial will show you how to change number of columns on search results page in Magento.<\/p>\n","protected":false},"author":93,"featured_media":65693,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[729],"tags":[656,2407,668,572,1303,631],"_links":{"self":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/65690"}],"collection":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/users\/93"}],"replies":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/comments?post=65690"}],"version-history":[{"count":0,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/65690\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media\/65693"}],"wp:attachment":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media?parent=65690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/categories?post=65690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/tags?post=65690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}