Try the Demo

Magento Forum

   
Page 2 of 3
Remove Category option from Layered Navigation options list
 
merigold
Sr. Member
 
Total Posts:  207
Joined:  2009-04-22
 
Mat.Owens - 17 March 2009 09:51 AM

This is what I did to remove the “Category” section from my layered navigation so I wouldnt have any repeat information with the attributes I wanted in the layered navigation.

go to app/design/frontend/default/default/template/catalog/layer and open up view.phtml for edit.

This is the code I have within the “dl” tags:

<dl id="narrow-by-list">
<?php $_filters $this->getFilters() ?>
<?php 
foreach ($_filters as $_filter): ?>
 <?php 
if($_filter->getItemsCount()): ?>
<?php 
if($_filter->getName() != "Category"){ ?>
<dt><?php echo $this->__($_filter->getName()) ?></dt>
<
dd>
<?php echo $_filter->getHtml() ?>
</dd>
<?php } endif; ?>
<?php 
endforeach; ?>
</dl>

All I did was add the if statement to allow everything in layered navigation except the group with the name of “Category.” I dont have Minimal Price in my nav but Im sure this would work for that too, just add it in the if statement.  My view.phtml file is attached.

Thanks!! it works for me to remove category option from layered navigation.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Adjustware
Guru
 
Avatar
Total Posts:  654
Joined:  2009-05-11
 

Note, that if you remove categories from the template only, magento still makes database queries and works (a little bit) slower.

 Signature 

AITOC Mods for Magento
Join AITOC on Facebook for exclusive deals

 
Magento Community Magento Community
Magento Community
Magento Community
 
Adjustware
Guru
 
Avatar
Total Posts:  654
Joined:  2009-05-11
 

You can also removes (or change display style )of the categories with our new Layered navigation Pro extension.
Note, that we use SEO-friendly urls in the categories (not blah-bla?cat=34)

Online demo available: http://demo-2.adjustware.com

 Signature 

AITOC Mods for Magento
Join AITOC on Facebook for exclusive deals

 
Magento Community Magento Community
Magento Community
Magento Community
 
derekycchan
Jr. Member
 
Total Posts:  7
Joined:  2009-09-20
 

i messed up with my view.phtml. Can anyone attach me a original copy of view.phtml file for version 1.3.2.4?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Adjustware
Guru
 
Avatar
Total Posts:  654
Joined:  2009-05-11
 

Here you are:

File Attachments
view.phtml  (File Size: 3KB - Downloads: 319)
 Signature 

AITOC Mods for Magento
Join AITOC on Facebook for exclusive deals

 
Magento Community Magento Community
Magento Community
Magento Community
 
derekycchan
Jr. Member
 
Total Posts:  7
Joined:  2009-09-20
 

Thanks man! grin

 
Magento Community Magento Community
Magento Community
Magento Community
 
Petralian
Jr. Member
 
Avatar
Total Posts:  15
Joined:  2009-09-03
Hong Kong
 

there is the php messing which can possibly break your installation but if you want to play it according to the Magento rules and use the layout xml files…

1. open app\design\frontend\yourpackage\yourtemplate\layout\catalogsearch.xml
2. replace
<block type="catalogsearch/layer" name="catalogsearch.leftnav" after="currency" template="catalog/layer/view.phtml"/>
with
<!-- <block type="catalogsearch/layer" name="catalogsearch.leftnav" after="currency" template="catalog/layer/view.phtml"/> -->

3. open app\design\frontend\yourpackage\yourtemplate\layout\catalog.xml
4. replace
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
with
<!-- <block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/> -->

 Signature 

http://www.petralian.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
Adjustware
Guru
 
Avatar
Total Posts:  654
Joined:  2009-05-11
 

Hi stass, As far as I understand, your code removes the layered navigation entirely from the catalog and search sections.  However the question is “How to remove ONLY categories from the layered navigation”.

 Signature 

AITOC Mods for Magento
Join AITOC on Facebook for exclusive deals

 
Magento Community Magento Community
Magento Community
Magento Community
 
Petralian
Jr. Member
 
Avatar
Total Posts:  15
Joined:  2009-09-03
Hong Kong
 

yeah that’s true… it removes the entire “shop by” box… sorry I see now I misunderstood the question… you would need to alter php for removing the category option only like previous mentioned grin.

 Signature 

http://www.petralian.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
mjeebu
Jr. Member
 
Total Posts:  9
Joined:  2008-03-06
 

Another way to do this is via CSS, you will need to add the following bit of php to the following file:
\app\design\frontend\default\theme\template\catalog\layer\view.phtml
as follows:

<?php   
  $tmpTitle 
$this->htmlEscape($this->__($_filter->getName()));
  
$tmpTitle strtolower($tmpTitle);
  
$tmpTitle preg_replace("/[\s]+/""-"$tmpTitle);
?>

<dt class="<?=$tmpTitle?>"><?php echo $this->__($_filter->getName()) ?></dt>
<
dd class="<?=$tmpTitle?>">
<?php echo $_filter->getHtml() ?>
</dd>

What the first part does is take the “title” of the attributes (set in the Manage Attributes section in the back) and changes the “title” to lower case and places “-” in place of spaces (in case your attribute name is more than 1 word).

The second part then injects the $tmpTitle variable as a “class” tag for use with some CSS magic!

Now all you need to do is go into your CSS file and e.g. if you want to hide an attribute such as category, make a CSS entry as follows:

.layered-nav .category { displaynone}
or say you want to hide price:
.layered-nav .price { displaynone}

I found this technique gives me more control overall.  For instance, on some categories, I might want to display Price while on others I don’t.

Hope this helps somebody!  smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
MaxMaximus
Jr. Member
 
Total Posts:  4
Joined:  2010-01-09
 

Hope this helps somebody!  smile

mjeebu You are genius, thank you soooo much, for this.

 
Magento Community Magento Community
Magento Community
Magento Community
 
fyodor
Member
 
Avatar
Total Posts:  50
Joined:  2008-09-12
 

really useful, thanks!

 Signature 

Magento 1.6.1

 
Magento Community Magento Community
Magento Community
Magento Community
 
Senetor
Sr. Member
 
Avatar
Total Posts:  259
Joined:  2009-03-26
Denmark
 

What if you don’t want to remove the categories, but will make them links to sub categories ( with filter category still working )…

so url becomes: myshop.de/category/cat2.html

instead of.. myshop.de/category.html?filtercat333y=34r

 Signature 

Anders Nielsen

Køb rigtig gode japanske knive

 
Magento Community Magento Community
Magento Community
Magento Community
 
loeffel
Guru
 
Avatar
Total Posts:  412
Joined:  2009-02-03
 

Fantastic, mjeebu. Working like a charm!

 Signature 

Erotikshop

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jubba
Sr. Member
 
Avatar
Total Posts:  82
Joined:  2009-05-07
London
 
mjeebu - 15 December 2009 05:56 PM

Another way to do this is via CSS, you will need to add the following bit of php to the following file:
\app\design\frontend\default\theme\template\catalog\layer\view.phtml
as follows:

<?php   
  $tmpTitle 
$this->htmlEscape($this->__($_filter->getName()));
  
$tmpTitle strtolower($tmpTitle);
  
$tmpTitle preg_replace("/[\s]+/""-"$tmpTitle);
?>

<dt class="<?=$tmpTitle?>"><?php echo $this->__($_filter->getName()) ?></dt>
<
dd class="<?=$tmpTitle?>">
<?php echo $_filter->getHtml() ?>
</dd>

What the first part does is take the “title” of the attributes (set in the Manage Attributes section in the back) and changes the “title” to lower case and places “-” in place of spaces (in case your attribute name is more than 1 word).

The second part then injects the $tmpTitle variable as a “class” tag for use with some CSS magic!

Now all you need to do is go into your CSS file and e.g. if you want to hide an attribute such as category, make a CSS entry as follows:

.layered-nav .category { displaynone}
or say you want to hide price:
.layered-nav .price { displaynone}

I found this technique gives me more control overall.  For instance, on some categories, I might want to display Price while on others I don’t.

Hope this helps somebody!  smile

I want to style the category section in Layered nav separatly from the rest of the layered nav and thought I could use this code in 1.4 to enable seperate css classes but it wont work.

any suggestions Please.....

 Signature 

Brain surgery is probably easier than this......no one said it would be easy!
http://www.tapstore.com

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 2 of 3