Page 3 of 5

Re: Accordion Menu R2

Posted: Tue Oct 20, 2009 3:11 pm
by Tony Barnes
Ah, is that what that was for, sorry, i hadn't followed it very well :oops:

Re: Accordion Menu R2

Posted: Tue Oct 20, 2009 6:54 pm
by Painstik
Tony Barnes wrote:Ah, is that what that was for, sorry, i hadn't followed it very well :oops:
I elaborated now with pictures... i think... :P

Re: Accordion Menu R2

Posted: Tue Mar 02, 2010 10:53 pm
by mu574rd
Painstik wrote:I recommend this php / html code modification instead of jquery accordion menu, effect is the same, the only thing is that there is no animation...

http://www.interspired.net/forum/viewto ... f=12&t=262


The problem is the "quoted" version does NOT work with ISC 5.5X and up. It is only compatible with 5.0X.
The jquery one listed here WORKS with the newer versions, and it works WELL.

Re: Accordion Menu R2

Posted: Wed Sep 01, 2010 1:44 pm
by pagreen07
I have this code implemented here (in staging):

http://74.119.234.6/~gingerbr/

This is the javascript I'm using:

<script type="text/javascript">
function initMenu() {
$('#SideCategoryList ul ul').hide();
$('#SideCategoryList li a').click(
function() {
var checkElement = $(this).next();
if(checkElement.is('ul')) {
$(this).next().slideToggle('fast');


return false;
}
}
);

}
$(document).ready(function() {initMenu();});
</script>

It works good - EXCEPT - that once a user arrives at the page they want to be on....the menu is collapsed. I'd like the active menu item to remain expanded. Is this possible? Has anyone figured out a modification for this?

Re: Accordion Menu R2

Posted: Tue Sep 07, 2010 11:38 am
by Tony Barnes
I don't think anyone has sorted that yet, no. Hmmmm, I may go on the hunt though, just thought of a method that may work

Re: Accordion Menu R2

Posted: Wed Sep 08, 2010 11:20 am
by Tony Barnes
Right, how's about this little bit of loveliness!!

Change your document ready function to this:

Code: Select all

$(document).ready(function() {
	initMenu();
	var m = location.href;
	$("a[href="+m+"]").parent().parent().parent().parent().show();
	$("a[href="+m+"]").parent().parent().show();
	$("a[href="+m+"]").css("font-weight","bold");
});
It will expand the relevant section, and also bold the section you are in! Boyah :D :D

I've got it set up there for a 3 level structure:

Home>Category>Child>Grandchild

If you want to go any further, so >Greatgrandchild, add this in at the top

Code: Select all

	$("a[href="+m+"]").parent().parent().parent().parent().parent().parent().show();
And it should show it all.

Re: Accordion Menu R2

Posted: Wed Sep 08, 2010 11:35 am
by CharlieFoxtrot
I'm very impressed! Congratulations!

Re: Accordion Menu R2

Posted: Wed Sep 08, 2010 11:47 am
by Tony Barnes
Aw shucks :oops:

Embarrassingly enough I did have have to get help on the jquery forum, turns out I'd bloody written part of it in PHP and not realised! lmao

Re: Accordion Menu R2

Posted: Wed Sep 08, 2010 5:17 pm
by Tony Barnes
Some more testing of this, a couple of niggles - if you go to a second page in a category it fails, and if you go down into a product it again closes. Will look into the logic, as should be solvable...

Re: Accordion Menu R2

Posted: Thu Sep 09, 2010 10:40 am
by Tony Barnes
Ok, this took longer than hoped, but here we go:

Code: Select all

$(document).ready(function() {
	initMenu();

	var m = location.href;
	var n = m.substring(0,m.indexOf('?'));

	if (n.length < 5) {
	$("a[href="+m+"]").parent().parent().parent().parent().show();
	$("a[href="+m+"]").parent().parent().show();
	$("a[href="+m+"]").css("font-weight","bold");
	}
	else { 
	$("a[href="+n+"]").parent().parent().parent().parent().show();
	$("a[href="+n+"]").parent().parent().show();
	$("a[href="+n+"]").css("font-weight","bold");
	}

	var p = $('#ProductBreadcrumb li:last').prev().html();
	l = p.indexOf("=") + 2;
	r = p.indexOf(">") - 1;
	p = (p.substring(l, r));
	$("a[href="+p+"]").parent().parent().parent().parent().show();
	$("a[href="+p+"]").parent().parent().show();
	$("a[href="+p+"]").css("font-weight","bold");

});
This now works on categories with multiple pages, and also keeps the menu open on the product page. It currently highlights the category in the breadcrumb as well, but meh, I can live with that!!!