ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

jquery accordion menu and current page?

February 11, 2010 6:08pm

Subscribe [2]
  • #1 / Feb 11, 2010 6:08pm

    JenSkim

    197 posts

    Hello.

    I’ve been able to get accordion menu to work beautifully, but I’d like it to open when I’m on whatever current page. Is there a way to tell the navigation to open, based on the current page?

  • #2 / Feb 11, 2010 6:58pm

    ender

    1644 posts

    I did that for the accordion I used on one site.  http://www.keytosavannah.com/listings/browse/category/restaurants/ should open you to the dining & nightlife section of the accordion.  as I recall I had to create a custom plugin to output the categories the right way and I kept a counter variable in PHP that output which accordion index to activate…

    you can see this code in the source, this is the end result:

    $(document).ready(function() {
        $('.accordion').accordion("activate",1)
    });
  • #3 / Feb 11, 2010 9:18pm

    smartpill

    456 posts

    There’s a built-in option (see docs):

    $("#whatever_you_called_it").accordion({
                navigation: true
            });
  • #4 / Feb 12, 2010 12:55am

    Jose B

    313 posts

    Would love to be able to do this with a menu full of categories of organizations. Is that possible? Seems like you have to type all the links.

  • #5 / Feb 12, 2010 9:40am

    ender

    1644 posts

    There’s a built-in option (see docs):

    $("#whatever_you_called_it").accordion({
                navigation: true
            });

    nice, hadn’t seen that option before… was it in there back when the latest version of jQuery was 1.2.x?

  • #6 / Feb 12, 2010 12:47pm

    JenSkim

    197 posts

    So, are you saying that (following comes from referenced docs page):

    jQuery(document).ready(function(){
        $('.accordion .head').click(function() {
            $(this).next().toggle();
            return false;
        }).next().hide();
    });

    you just add to it:

    $("#whatever_you_called_it").accordion({
                navigation: true
            });

    for a total script result of:

    jQuery(document).ready(function(){
        $('.accordion .head').click(function() {
            $(this).next().toggle();
            return false;
        }).next().hide();
            $("#whatever_you_called_it").accordion({
                   navigation: true
            });
    })
  • #7 / Feb 12, 2010 1:15pm

    ender

    1644 posts

    no, navigation:true needs to be added to the accordion config object when you first call the .accordion() function on your jQuery-wrapped DOM element.

  • #8 / Feb 18, 2010 1:58pm

    JenSkim

    197 posts

    Can you share you Expression Engine code and tags with me? I’m still struggling with this… Thank you.

  • #9 / Feb 18, 2010 2:26pm

    ender

    1644 posts

    I built a plugin for that particular instance because the stuff I needed to output wasn’t possible to efficiently get using template tags (categories, sub-categories, sub-sub-categories, number of entries within each one), so it wouldn’t help you terribly much I’m afraid.

    Always available for consulting though if you’ve hit a wall and need some hands-on assistance.  Just let me know.

  • #10 / Feb 18, 2010 2:58pm

    JenSkim

    197 posts

    Thanks! Here’s my menu code. the script is making the category headers, but when you click on them, they do not open up to a list of entries that share that category - shown below the accordion menu.

    Here’s the page, with tests in place:

    http://www.utexas.edu/cie/story/my-first-story


    Code for normal category-driven menu:

    
    
    

    Code for accordion category-driven menu:

    
    
    

    Thanks so much for taking a look at this!!

  • #11 / Feb 18, 2010 4:49pm

    JenSkim

    197 posts

    I have since taken down this testing code… gotta move on. Let me know when you have time to look at this and I’ll repost. Thanks!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases