Jump to content

[SOLVED] how to close subcategories in block categories


Recommended Posts

hello,

 

I can't figure out how to open 1 category at a time and close other open categories in block categories?

I maen right now i can expand as many categories as i want, but i want the user to be able to expand only 1 category at a time?

 

Thanks!!!

Edited by vekia (see edit history)
Link to comment
Share on other sites

hello

it will be necessary to alter module js file and add new event to onclick action

 

what theme you use? what prestashop version? you're reffering to default block categories module (if so - what version - exact number)

Link to comment
Share on other sites

Thank you very much for the reply.

I figured it out my self ;)

 

 

I am writing the details in case if somebody else wants to implement it.

The file responsible for the animations of block category is located inside "themes/your_theme/js/tools". the file is called treeManagement.js

 

you have to do some changes inside openBranch function.

and here is my code...

//animate the opening of the branch (span.grower jQueryElement)
function openBranch(jQueryElement, noAnimation) {
		$( ".tree ul li ul" ).each(function() {
		var item = $( this );
		  if(item.css('display') == 'block'){
			item.parent().find("span:first").removeClass('OPEN').addClass('CLOSE');;
			item.hide();
		  }
		});
		
		
		
		jQueryElement.addClass('OPEN').removeClass('CLOSE');
		if(noAnimation) {
			//jQueryElement.parent().find('ul:first').show();
			jQueryElement.parent().find('ul:first').prev().addClass('opened');
		}
		else {
			jQueryElement.parent().find('ul:first').show();
			jQueryElement.parent().find('ul:first').prev().addClass('opened');
		}
}

Moderators please change the title of this thread to something that would make it easier for people who need this code to find.

Edited by ufo973 (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...