Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 2 of 3
Remove Category option from Layered Navigation options list
 
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.

 
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

 
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: 402)
 
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"/> -->

 
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”.

 
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.

 
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
 
AlexisU
Member
 
Avatar
Total Posts:  50
Joined:  2008-09-12
 

really useful, thanks!

 
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

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

Fantastic, mjeebu. Working like a charm!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jubba
Sr. Member
 
Avatar
Total Posts:  82
Joined:  2009-05-07
London
 
mjeebu - 15 December 2009 04: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.....

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jubba
Sr. Member
 
Avatar
Total Posts:  82
Joined:  2009-05-07
London
 

Just in case this helps any one this works well on 1.4 \’Quick Product Finder\’ can be changed to what you would like could be \’Shop By\’

when you have replaced the view.phtml with the below just create the css required to style individual parts of the layered nav as you wish,
i.e .block-layered-nav .up_ddCategory { } or .block-layered-nav .up_dtCategory { }.

then if any item you wish to remove use the { display: none; } in your styles.css

you can see the result example

<?php if($this->canShowBlock()): ?>
<div class="block block-layered-nav">
    
    <
div class="block-content">
        
<?php echo $this->getStateHtml() ?>
        <?php 
if($this->canShowOptions()): ?>
            
<class="block-subtitle"><?php echo $this->__('Quick Product Finder'?><p>
            <
dl id="narrow-by-list">
                
<?php $_filters $this->getFilters() ?>
                <?php 
foreach ($_filters as $_filter): ?>
                <?php 
if($_filter->getItemsCount()): ?>
                <?php $__tcc
=$this->__($_filter->getName());?>
                    
<dt class="<?php echo "up_dt".$__tcc;?>">
                    
<?php echo $__tcc;?>
                    
</dt>                    
                   <
dd class="<?php echo "up_dd".$__tcc;?>">
                   
<?php echo $_filter->getHtml() ?>
                  
</dd
                
<?php endif; ?>
                <?php 
endforeach; ?>
            
</dl>
            <
script type="text/javascript">decorateDataList('narrow-by-list')<script>
        
<?php endif; ?>
    
</div>
</
div>
<?php endif; ?>
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 3