jcadima
5/20/2015 - 6:34 PM

Get Current Category

Get Current Category

<?php
// 

// GET CURRENT CATEGORY
$category = Mage::getModel('catalog/layer')->getCurrentCategory();
// make banner image col-lg-12 only if we are on 'About Us' Page, else use col-lg-9
$fullbanner = ( $category->getId() == 11 ) ? '12' : '9' ; 

if ($_imgUrl = $_category->getImageUrl()) {
    $_imgHtml = '<div class="col-lg-' . "$fullbanner" . ' category-head-image"><p class="category-image"><img class="img-responsive" src="'.$_imgUrl.'" alt="'.$this->escapeHtml($_category->getName()).'" title="'.$this->escapeHtml($_category->getName()).'" /></p></div>';
    $_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
}


// SHOW IMAGE BANNER FOR SOME CATEGORY PAGES ONLY
		if( $_imgUrl && !in_array($category->getId(), $cat_ids) ):
	         echo $_imgHtml
 endif;
 
 /*  
 Since $_imgUrl is being echoed on line 17, we dont need to echo $fullbanner on 
 line 10, it can just be placed there and line 17 will take care of echoing the
 html along with $fullbanner
 */