<div class="left-category"><?php echo $this-> __('CATEGORIES')?></div>
<div class="maincategory">
<?php
$_helper = Mage::helper('catalog/category');
$_categories = $_helper->getStoreCategories();
$currentCategory = Mage::registry('current_category') ;
$rootCategoryId = Mage::app()->getStore()->getRootCategoryId();
$rootCategory = Mage::getModel('catalog/category')->load($rootCategoryId);
$childIds = explode(',',$rootCategory->getChildren());
if (count($childIds) > 0):
?>
<?php foreach($childIds as $_category):
$_category = Mage::getModel('catalog/category')->load($_category);
?>
<div class="maincatdiv">
<div class="catheader">
<span class="category_name">
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
<?php echo $_category->getName() ?></a></span>
<?php if ($_category->getChildren() != ''){?><span class="caticon">+</span><?php } ?>
</div>
<div class="catcontent" style="display:none;"><?php
if ($_category->getChildren() != ''):
$allsubchild = explode(',',$_category->getChildren());
?>
<ul>
<?php foreach($allsubchild as $_sub):
$_subcategory = Mage::getModel('catalog/category')->load($_sub);
?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
<?php echo $_subcategory->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?></div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<script type="text/javascript">
jQuery(window).load(function(){
jQuery('.caticon').click(function(){
var str = jQuery(this).closest('.maincatdiv').find('.catcontent').html().split(' ');
if(str[0] != '')
{
if(jQuery(this).attr('class').indexOf('active') != -1)
{
jQuery('.catcontent').slideUp();
jQuery('.caticon').removeClass('active');
jQuery('.caticon').html('+');
}
else{
jQuery('.catcontent').slideUp();
jQuery('.caticon').removeClass('active');
jQuery('.caticon').html('+');
jQuery(this).addClass('active');
jQuery(this).html('-');
jQuery(this).closest('.maincatdiv').find('.catcontent').slideDown();
}
}
});
})
</script>
This blog is all about magento , php javescript ,mysql codes. In this i am trying to post the posts which i really feel to have these codes always with me and i am trying to publish most challenging codes which we need to use in daily development. I personally sometime needs to spent most of times to get the idea about these codes on net,thats why i thought to put all these codes on one place and i am trying to keep this work going on and in simple way which can help the communty
Wednesday, 12 November 2014
Magento Left Category with jquery
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment