Posts Tagged ‘edit magento’

How to remove the ‘Shop By’ box from the left column in Magento

December 1, 2010

To activate and deactivate widgets in Magento like the Newsletter option, it’s pretty easy. You just go to System/Configuration/Advanced and select ‘disable’ next to the ‘Mage_Newsletter’ item.

But what if you want to disable something that has no apparent widget control? I couldn’t find a widget that controlled the ‘Shop By’ option in the left column. If there is a widget that controls this, please let me know!

The first way to remove an item – edit the code from the referenced PHTML file

What I did was to first identify the name of the DIV that contained it .To do this, visit a page containing the item on your testing or live server, select ‘view source’, copy the source code in its entirety and paste it into a new, blank HTML Dreamweaver file. Working in Split View, you can click on DIVs in the Design Pane and see what they are called in the Code Pane.

I established that the code in question was within the “block block-layered-nav” DIV. In Dreameaver Files, select the app/design/frontend/base directory and perform a search for “block block-layered-nav” in the source code of all selected files. Click ‘Find All’.

The search showed that two files contained this css string – the view.phtml and left.phtml files. Upon inspection, the view.phtml file contained the ‘Shop By’ title, so this was the one to edit. You could either comment out all the PHP and HTML, or (as I did) empty the file after making a copy of it for later reinstatement if required.

Upload the file to app/design/frontend/default/yourtheme/template/catalog/layer and the item should disappear from the left column.

If you are wondering why we retrieved the view.phtml from the Base theme rather than your theme, it’s because sometimes not all the phtml files exist in a theme, and when this happens Magento defaults to the Base theme to find one. By uploading it to the same location in your theme, it overrides the default Base version.

Of course, if you have a view.phtml already in your theme, edit that one.

The second way to remove an item – edit the code from the referencing XML file

Now you know where the code resides, you can perform a new search of the app/design’frontend/base directory for the filename, ‘view.phtml’. This showed quite a few files referencing view.phtml, but only two which were referenced view.phtml in the layer directory: catalog.xml and catalogsearch.xml.

Just focusing on the catalog.xml file (which affects more pages), locate the reference of layer/view.phtml in the code. It appeared just once on line 115. Comment out the code that references the file, replacing this:

<reference name="left">

<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>

</reference>

with this:

<!--COMMENTED OUT TO REMOVE *SHOP BY* START

<reference name="left">

<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>

</reference>

COMMENTED OUT TO REMOVE *SHOP BY* END-->

Save the catalog.xml file to the corresponding directory in your theme (if it doesn’t already exist): app/design/frontend/default/yourtheme/layout

Now the Shop By option should have left the site.