Skip to content

Instantly share code, notes, and snippets.

@brankoajzele
Created January 12, 2015 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brankoajzele/083ff8a07ab655c2f8da to your computer and use it in GitHub Desktop.
Save brankoajzele/083ff8a07ab655c2f8da to your computer and use it in GitHub Desktop.
<style>
#current-category-content ul {
padding-left: 20px;
}
.elastic-active-category-title span {
color: silver;
}
</style>
<div class="block block-list block-current-category">
<div class="block-title">
<strong><span><?php echo $this->__('Show results for') ?></span></strong>
</div>
<div id="current-category-content" class="block-content">
<?php if (!empty($_GET['cat'])): ?>
<div class="elastic-active-category-title"><span>&raquo; </span><?php echo Mage::getModel('catalog/category')->load((int)$_GET['cat'])->getName() ?></div>
<?php else: ?>
<div class="elastic-active-category-title"><span>&raquo; </span><?php echo Mage::registry('current_category')->getName() ?></div>
<?php endif; ?>
</div>
</div>
<script type="text/javascript">
//<![CDATA[
<?php if (!empty($_GET['cat'])): ?>
var currentCategoryId = <?php echo (int)$_GET['cat'] ?>;
<?php else: ?>
var currentCategoryId = <?php echo Mage::registry('current_category')->getId() ?>;
<?php endif; ?>
jQuery('#elastic-category-'+currentCategoryId).parents().each(function(){
<?php /* Check if we reached top of the tree, then break loop */ ?>
if (jQuery(this).attr('id') === 'elastic-category-listing') {
return false;
}
<?php /* Build Amazon style "back to category" links */ ?>
if (jQuery(this).attr('id') !== undefined) {
var categoryLink = jQuery(this).find('a');
jQuery('#current-category-content').prepend(
jQuery('<div/>', {
'html': '&laquo; ',
'class': 'elastic-category-upper-level-wrapper'
}).append(jQuery('<a/>', {
'html': categoryLink.html(),
'href': categoryLink.attr('href'),
'class':'elastic-category-upper-level-link'
}))
);
}
});
if (jQuery('#elastic-category-'+currentCategoryId+' > ul').length != 0) {
var availableCategories = jQuery('<ul/>');
jQuery('#elastic-category-'+currentCategoryId+' > ul').children().each(function (){
availableCategories.append(jQuery('<li/>').append(jQuery(this).find('a:first')));
});
jQuery('#current-category-content').append(availableCategories);
}
jQuery('#elastic-category-listing').remove();
//]]>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment