Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-04-14 20:39:05

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Menu listing categories and on click expand to show all articles

Hi everyone,

I was asked to create a – for me – tricky menu…

In its initial state it should show two specific parent categories and all child categories like so:

Parent Cat 1
  • Category 1
  • Category 2
  • Category 3
  • Category 4
  • Category 5
Parent Cat 2
  • Category 6
  • Category 7
  • Category 8

If the visitor clicked on e.g. Category 2 it should expand to show all associated articles like so:

Parent Cat 1
  • Category 1
  • Category 2
    • Article 1
    • Article 2
    • Article 3
    • Article 4
    • Article 5
  • Category 3
  • Category 4
  • Category 5
Parent Cat 2
  • Category 6
  • Category 7
  • Category 8

At the moment I’m thinking of hard-coding the category links, since they’re not likely to change often, and then use a bunch of conditionals to display the respective articles on the category landing page.

But is there a better way to pull this off, an accordion effect perhaps?
Ideally I’d want any new child categories to appear automatically, which isn’t possible, if it’s hard-coded.

I’m open to any suggestions and any help would be very much appreciated.

Cheers Martin

Offline

#2 2008-04-15 06:01:29

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

Re: Menu listing categories and on click expand to show all articles

would one of the category plugins help?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2008-04-15 11:20:24

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: Menu listing categories and on click expand to show all articles

I’ve looked through them all, to no avail.

Some do nested listing of specific categories just fine, but I couldn’t find one that can “inject” an article listing depending on the currently viewed category.

Last edited by masa (2008-04-15 11:20:45)

Offline

#4 2008-04-15 15:50:51

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Menu listing categories and on click expand to show all articles

Hi, I made a similar menu recently to permit navigation through a collection of 50 or so classic cars without the help of a TXP plug-in but using Jquery and a Jquery plug-in. I made four parent categories:

  • Car Genres – e.g. Classic Sports Car, Vintage Sports Car, Luxury Car etc
  • Marques A-D – e.g. Alfa Romeo, Audi, Brabham, etc
  • Marques E-N – e.g Ferarri, Ford etc
  • Marques O-Z – e.g. Renault, Rolls-Royce etc

In this case, an Alfa Romeo sports car could be classified as a Classic Sports Car (Car Genres) and as an Alfa Romeo (Marques A-D) and so on.

<txp:category_list parent="Car-Genres" exclude="Car-Genres" break="li" wraptag="ul" active_class="active" type="article"/>

and for the marques

<txp:category_list parent="Marques-A-to-D" exclude="Marques-A-to-D" break="li" wraptag="ul" active_class="active" type="article"/> and so on.

To produce a menu, it was easy to incorporate this into an accordion that behaved in the manner you described. Jquery and the Jquery accordion plug-in would be a good start point for that.

I did what you suggested and had the menu link (category) lead to a category page that listed all the Alfas or whatever but could equally have made each of the Alfas the child of the Alfa marque (itself, a child of the Marque parent) and used some other appropriate Jquery plug-in such as Tree View that can cope with sub levels and sub sub levels.

Obviously, the best way to do it depends on how dynamic your categories and their parents are.

Hope this helps.

Last edited by joebaich (2008-04-16 11:50:17)

Offline

#5 2008-04-16 19:16:46

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: Menu listing categories and on click expand to show all articles

joebaich wrote:

I did what you suggested and had the menu link (category) lead to a category page that listed all the Alfas or whatever but could equally have made each of the Alfas the child of the Alfa marque (itself, a child of the Marque parent) and used some other appropriate Jquery plug-in such as Tree View that can cope with sub levels and sub sub levels.

Joe, thanks for the reply.

I admit, I’m bit lost here. I figure the code sample you posted, would expand the sub-categories, but how would I go about displaying the articles contained?

Any further tips?

Cheers Martin

Offline

Board footer

Powered by FluxBB