Show/hide part of a menu

  • tofkop

    #3790

    Hey, first of all thanks for the great theme!

    On my website i would like to have a menu in my sidebar that could show and hide a part of itself.

    I have a menu with let’s say 30 Brands. I would like that it only shows the first 5(or another number) and display’s “show more” underneath it. When you click it it show’s the full menu with all the brands and “less” underneath it.

    I could code it in javascript in the HTML, but i would prefer to edit a widget to do this, i don’t like it hardcoded, and i think it shouldn’t be that difficult. The problem is i don’t know where i could start doing it. Where can i find the php file i need? Could you point me out?

    You can see what i want on http://www.fishandchips.be/test2/wordpress/, the brands-menu on the right, hardcoded in javascript.

    Mod

    Kenneth John Odle

    #25953

    Create a custom menu and then use that in your javascript.

    Actually, there are at least a couple of plugins that will handle this for you. Try searching the plugin repository for “accordion menu”. You may need to add “vertical” to that search. I’ve seen a couple of Graphene and a couple of non-Graphene sites that do this. It’s pretty cool.

    tofkop

    #25954

    Thats what i used at the moment, a custom menu, copied the generated code and put that in a javascript in a text/html widget.

    What i want to do is to generate the menu instead of hardcode it, so that if a certain brand/category doesn’t have any items it stays hidden, and if i remove/add a brand/category it’s added to the menu.

    So what i want to do is create a widget to get all the categories, and put them in an array. On loading the page i make a loop asking for the first x items in the array, and put a “show more” link after. When that link is clicked, we generate the rest of the categories and replace the “show more” link with a show less.

    Should i use php or JQuery for this? Or a mix? Can i add this to the theme?

    Most of the plugins i found are or showing all the categories, or none. Or showing the main categories and onclick the subcategories. This isn’t what i need and i couldnt find any plugin yet for doing this.

Viewing 3 posts - 1 through 3 (of 3 total)

  • You must be logged in to reply to this topic.