Solved

Echo subcategory description in navigation menu Magento

Posted on 2013-01-09
9
1,383 Views
Last Modified: 2016-03-02
I'm trying to find a way to show the short description for subcategories in Magento nav menu.

So far I have used this:

<?php echo $this->htmlEscape($_subcategory->getDescription()) ?>

Open in new window


But nothing shows. I have also changed it to this:

<?php echo $this->htmlEscape($_category->getDescription()) ?>

Open in new window


Which shows the parent category description.

Does any know how to do this? If you are willing to share I'd be very grateful.
0
Comment
Question by:rafique12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 12

Expert Comment

by:sivagnanam chandrakanth
ID: 38762377
0
 

Author Comment

by:rafique12
ID: 38762471
Thankyou for the response,

Yes I had followed this tutorial but my code is setup differently. I am using a vertical flyour menu (similar to Amazon) with parent categories which flyout to show subcategories with a thumbnail and (hopefully) subcategory description.

However, at the moment I can only get the description of the parent category to show foreach subcat which is very frustrating...

<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if (count($_categories) > 0): ?>
<div class="left-nav-vertical visible-desktop visible-tablet hidden-phone" id="nav-vertical">
<ul class="nav nav-tabs-left"> 
<li class="dropdown open visible-desktop visible-tablet hidden-phone" id="left"> 
<a class="dropdown-toggle"><?php echo $this->__('Shop by Department') ?><b class="caret"></b></a> 
<ul class="dropdown-menu"> 
<div class="dcjq-vertical-mega-menu">                                  
<ul id="mega" class="menu"> 
<!--Top Category--> 
<?php foreach($_categories as $_category): ?> 
<li id="menu-item-1">
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>"> <?php echo $_category->getName() ?></a>
<ul> 
<?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
<?php $_subcategories = $_category->getChildrenCategories() ?>
<?php if (count($_subcategories) > 0): ?>
<?php foreach($_subcategories as $_subcategory):$products = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($_subcategory)->addAttributeToSelect('small_image');$products->getSelect()->order(new Zend_Db_Expr('RAND()'))->limit(1);$products->load();?> 
<!-- SubCategory--> 
<ul> 
<li id="menu-item-19">
<a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>" class="pull-right">
<span><p class="product-name"><?php echo $_subcategory->getName() ?></p> </a> 
<?php foreach($products as $product) { ?>
<?php $cur_category=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category); ?>
<a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>" class="pull-left">
<img src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(50, 50); ?>" class="static-thumbs" width="50" height="50" alt="<?php echo $_subcategory->getName() ?>" /></a>
<li id="menu-item-4" class="pull-right">
<em><?php echo $this->getCurrentCategory()->getDescription() ?></em></span>
<?php break; } ?>
</li> 
</ul> 
<div class="clearer"></div>
<!-- end of subcats -->
<?php endforeach; ?> 
</li> 
<?php endif; ?>  
</ul> 
<!-- end of parent cats -->
<?php endforeach; ?> 
</li> 
</ul> 
</div> 
</ul> 
</li> 
</ul>
</div> 
<?php endif; ?>
<!--- Closed Navigation Menu -->

<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function(){
  jQuery('#mega').dcVerticalMegaMenu({
    rowItems: '1',
    speed: 'fast',
    effect: 'slide',
    direction: 'right'
  });
});
</script>
<!--- Closed Navigation Menu -->

Open in new window

0
 
LVL 12

Expert Comment

by:sivagnanam chandrakanth
ID: 38762480
I dont think you have any other alternate solution
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Expert Comment

by:EddieShipman
ID: 38762981
Did you try:
<?php echo $this->htmlEscape($_subcategory->getName()) ?>

Open in new window


Essentially the Name is the Short Description. The categories model doesn't have a ShortDescription.

Also, check this out:
http://fishpig.co.uk/blog/category-navigation-listings-in-magento.html
0
 

Author Comment

by:rafique12
ID: 38763046
I have the name already but are you saying their isn't a way to show the description for a sub category - only the name?

If I include:

<?php echo $this->htmlEscape($_subcategory->getName()) ?>

Open in new window


I just get the name and not the description.

I'm not sure if I may have misunderstood your answer.
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 500 total points
ID: 38764156
You said "show the short description" There is no "Short Description" attribute for a category, only Name and Description.

Maybe this post will help you figure it out:
http://stackoverflow.com/questions/7201433/magento-displays-subcategories-description-on-category-list-phtml?rq=1
0
 

Author Comment

by:rafique12
ID: 38764460
Thankyou for the link, very close to a solution now as the subcategory description is showing.

I will accept your answer...
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 38764601
I thnk this was the key:
Mage::getModel( 'catalog/category' )->load( $child );

Open in new window

0
 

Author Comment

by:rafique12
ID: 38764676
Stilll a slight issue that I need to figure out as it loads every description foreach category.

instead of one per category. I think its the way my code is setup...

<span><em>
<?php $children = explode( ",", $this->getCurrentCategory()->getChildren() ); ?>
        <?php foreach( $children as $child ): ?>
            <?php $_child = Mage::getModel( 'catalog/category' )->load( $child ); ?>
            <li><?php echo $_child->getDescription(); ?></li>
        <?php endforeach; ?>
</em></span>

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CRM 2011 Advanced Find Producing Error 3 40
Wordpress -  Updating All Posts on Website 3 90
Joomla Editing 3 21
sitemap.xml 3 28
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question