Jump to content

Blockcategories modification


Recommended Posts

Hello,

I modified my blockcategories in order to make the parent category click to reveal sub-categories instead of redirecting to category page.
But now I've a strange bug, my category menu doesn't display the last sub-category of each category. It doesn't seems to be css related I checked with firebug

my treeManagement.js :

//animate the opening of the branch (span.grower jQueryElement)
function openBranch(jQueryElement, noAnimation) {
       jQueryElement.addClass('OPEN').removeClass('CLOSE');
       if(noAnimation)
           jQueryElement.parent().find('ul:first').show();
       else
           jQueryElement.parent().find('ul:first').slideDown();
}
//animate the closing of the branch (span.grower jQueryElement)
function closeBranch(jQueryElement, noAnimation) {
   jQueryElement.addClass('CLOSE').removeClass('OPEN');
   if(noAnimation)
       jQueryElement.parent().find('ul:first').hide();
   else
       jQueryElement.parent().find('ul:first').slideUp();
}

//animate the closing or opening of the branch (ul jQueryElement)
function toggleBranch(jQueryElement, noAnimation) {
   if(jQueryElement.hasClass('OPEN'))
       closeBranch(jQueryElement, noAnimation);
   else
       openBranch(jQueryElement, noAnimation);
}

//when the page is loaded...
$(document).ready(function () {
   //to do not execute this script as much as it's called...
   if(!$('ul.tree.dhtml').hasClass('dynamized'))
   {
       //add growers to each ul.tree elements
//        $('ul.tree.dhtml ul').prev().before(" ");
//$('ul.tree.dhtml ul').prev().each( function() {var textea = $(this).text();
//    $(this).replaceWith(""+textea+"");
//});
//add growers to each ul.tree elements
$('ul.tree.dhtml ul').prev().each( function() {
   var textea = $(this).text();
   if ( $(this).hasClass("selected") )
       $(this).replaceWith(""+textea+"");
   else
       $(this).replaceWith(""+textea+"");
});

       //dynamically add the '.last' class on each last item of a branch
       $('ul.tree.dhtml ul li:last-child, ul.tree.dhtml li:last-child').addClass('last');

       //collapse every expanded branch
       $('ul.tree.dhtml span.grower.OPEN').addClass('CLOSE').removeClass('OPEN').parent().find('ul:first').hide();
       $('ul.tree.dhtml').show();

       //open the tree for the selected branch
           $('ul.tree.dhtml .selected').parents().each( function() {
               if ($(this).is('ul'))
                   toggleBranch($(this).prev(), true);
           });
           toggleBranch( $('ul.tree.dhtml .selected'), true);

       //add a fonction on clicks on growers
       $('ul.tree.dhtml span.grower').click(function(){
           toggleBranch($(this));
       });
       //mark this 'ul.tree' elements as already 'dynamized'
       $('ul.tree.dhtml').addClass('dynamized');

       $('ul.tree.dhtml').removeClass('dhtml');
   }
});



maybe it's in my /modules/blockcategories/category-tree-branch.tpl

>

{$node.name|escape:html:'UTF-8'}

   {if $node.children|@count > 0}
</pre>
<ul>
       {foreach from=$node.children item=child name=categoryTreeBranch}
<!--             {if $smarty.foreach.categoryTreeBranch.last}
                       {include file=$branche_tpl_path node=$child last='true'}
           {else}  -->
                       {include file=$branche_tpl_path node=$child last='false'}
   <!--        {/if} -->

       {/foreach}
</ul>
<br>   {/if}<br



Thanks a lot for your help, I'm lost.

ps: I use the trick putting 1. , 2. , 3. etc.... in category name to order them my way

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...