Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-05-30 16:16:17

webclick
New Member
Registered: 2007-03-01
Posts: 3

Multiple-level tree navigation question

Maybe there is a plugin to do this, but I haven’t found anything yet, so here it is what I’m trying to do for a client:

I want to create a multi-level navigation, that would display the articles under certain category. Here an example: I’ll set up categories: top, a_level1, a_level2, a_level3 and so on. On the front end, like I said I want to show only the article that I’m assigning to those categories, not the categories name. Then for the user to add a link and an article would be as simple as creating the article and assigning a category, for example I can create a NEWS article in “top” category, a “ENTERTAINMENT” article in “a_level1”, a MOVIES “article” in “a_level2” category.

so the navigation in the front end would look like this:

NEWS
—-ENTERTAINMENT
———-MOVIES

So if the user wants to create a link of an article at the top level he would just create the article and assign it the category “top” for example “MUSIC”.

NEWS
—-ENTERTAINMENT
———MOVIES
MUSIC

An extra option that I think I can accomplish using <txp:if_category> would be to show only the top level if I’m at home page, show 2nd level if I’m in NEWS.

home page:
NEWS
MUSIC

news page:
NEWS
—-ENTERTAINMENT
MUSIC

thanks for your help!

Last edited by webclick (2007-05-30 16:20:36)

Offline

#2 2007-09-28 20:13:03

DC
New Member
Registered: 2004-05-29
Posts: 7

Re: Multiple-level tree navigation question

Looking for something similar. Any advice or solutions out there? I’ll need to figure out a solution this weekend or change platforms.

Offline

#3 2007-09-28 21:53:19

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: Multiple-level tree navigation question

Looking for something similar. Any advice or solutions out there?

Could you perhaps describe precisely what you yourself are trying to achieve? webclick’s description is not very easy to follow and mixes articles and categories, and does not mention sections at all.

Certainly there are lots of solutions for structuring and navigating a site. It is no problem to use a list of articles as a self-extending sub-menu for a category or a section. Normal txp:article / txp:article_custom lists together with section or category attributes and/or the txp:if_different tag are good starting points. Check the textbook alphabetical tag list for how they work. The FAQ also has some potentially useful articles.

I’ll need to figure out a solution this weekend or change platforms.

comes across a bit as an “or else” but I hope the above helps… perhaps we can help more if you tell us more.


TXP Builders – finely-crafted code, design and txp

Offline

#4 2007-09-28 22:55:38

DC
New Member
Registered: 2004-05-29
Posts: 7

Re: Multiple-level tree navigation question

Sorry about that. It’s not or else, I love this platform and what I’ve been able to figure out so far with it on several previous projects. It’s just that I have deadline on this project and am running out of time to learn new aspects of Textpattern.

My client’s site has the following sections: News, About, Services, Partners

News has two categories (news and events) (no problems here)
About is just a few static pages (again no problems)
Services and Partners have between 12 and 20 categories each, with some (or potentially all) of them being further divided. This is my problem area.

The sections need sticky text (solution known). Some of the categories may as well (not critical to project delivery). Partners and Services sections need to have headings & excerpts from each primary category article showing on the section landing page as well as the sticky text. Following a link to a main category article should then display the main category article as well as links to other articles in its category. This list of contextual links needs to be displayed in a sidebar and additionally could also go under the main article.

Any help will be gratefully appreciated. Maybe I can return the favour with some CSS wizardy—a topic I am much more expert at.

Last edited by DC (2007-09-28 22:56:34)

Offline

#5 2007-09-29 09:11:52

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: Multiple-level tree navigation question

…with some (or potentially all) of them [categories] being further subdivided.

This is the key phrase as to whether you can achieve this with txp.

For example the following is possible:

Services [section] > for Businesses [category] > Service A, Service B, Service C [articles] …
Services [section] > for Charities [category] > Service A, Service C, Service D [articles] …
Services [section] > for Freelancers [category] > Service B, Service E, Service F [articles] …
(a service [article] can be allocated to up to two categories at once)

But if you wanted to have:
Services [section] > for Businesses [category] > Sole Trader > Service A, Service B, Service C [articles] …
Services [section] > for Businesses [category] > 1-10 employees > Service A, Service B, Service C [articles] …
Services [section] > for Businesses [category] > 11-50 employees > Service A, Service B, Service C [articles] …
this does not work as txp does not have sub-categories or sub-sections.

The workaround is to combine categories into one, e.g.:
Services [section] > for Businesses – one-man [category] > Service A, Service B, Service C [articles] …
Services [section] > for Businesses – 1-10 employees [category] > Service A, Service B, Service C [articles] …
Services [section] > for Businesses – 11-50 employees [category] > Service A, Service B, Service C [articles] …

Thinking aloud here, you might be able to fake the third level in the navigation (not in the url structure, though) by assigning a custom field for the final category level and using txp:if_different to generate a list of articles according to that custom_field, e.g. in the example above, the custom field might be “for business size” with values of 1_10, 11_50, 50plus etc. Using txp:if_different (see article linked above), you can produce a list of articles grouped according to the custom field “for business size”. Note: this produces the navigation structure you want but out of the box the url will still be www.domain.tld/services/service-name. The plug-in gbp_permanent_links might help you get around this.

have headings & excerpts from each primary category article showing on the section landing page

txp:article is context-sensitive and lists articles differently depending upon context, e.g. a section landing page (list of articles in section), a category landing page (list of articles in category), an article (article itself). In your page template you can control this more specifically by explicitly stating what happens using conditional tags such as if_article_list, if_individual_article and if_category.

Use article forms to determine how the article or article list should show e.g. to show heading (with link) and excerpt make a form that shows <h1><txp:permlink><txp:title /></txp:permlink></h2><txp:excerpt> and specify it in txp:article using the attribute listform="myexcerptformname".

The sections need sticky text (solution known). Some of the categories may as well…

Several options:

  • if it never changes, hard code it into the appropriate bit of your page template. You can use txp:if_category to display different text for different category lists.
  • make it a sticky article and in your page template display the sticky articles first, then use txp:article to list the remaining status="live" articles.
  • If you want the text to be editable but want to avoid it appearing in other article lists/navigation, set it’s status to hidden (so other tags don’t list it), then instead of hard-coding it into the relevant part of your page template as above, use <txp:article_custom id="articleID#" form="myintrotextform" status="hidden" /> to specifically display that (normally) hidden article in the way you want it (as given in the form “myintrotextform”).
  • There are probably other ways too…

display the main [I guess you mean desired] category article as well as links to other articles in its category

This is the normal article view as produced by txp:article. In the page template this would be the if_individual–article view. Use txp:related_articles with the attributes match and possibly section if the same categories occur in two sections.

There are probably other ways of achieving the same or similar too, for instance much of txp:related_articles’s functionality can be achieved using txp:article_custom with various attributes.

Last edited by jakob (2007-09-29 09:12:30)


TXP Builders – finely-crafted code, design and txp

Offline

#6 2007-09-29 15:50:40

DC
New Member
Registered: 2004-05-29
Posts: 7

Re: Multiple-level tree navigation question

Thank you Jakob,

Your first example is what I’m after. I’ll have to dig into conditional statements; a topic that has eluded me so far.

Last edited by DC (2007-09-29 16:10:55)

Offline

#7 2007-10-01 18:14:15

DC
New Member
Registered: 2004-05-29
Posts: 7

Re: Multiple-level tree navigation question

Just thought I’d report back and let you know that once I got over my fear of conditional statements things worked out very well. I’m getting the site organized the way the client needs and that is always a good thing.

Offline

#8 2007-10-01 18:59:56

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: Multiple-level tree navigation question

Good for you * thumbs up *


TXP Builders – finely-crafted code, design and txp

Offline

#9 2007-10-02 06:19:11

Timid&friendly
Member
From: The Netherlands
Registered: 2006-05-28
Posts: 252
Website

Re: Multiple-level tree navigation question

I’m a txp noob, but i thought that it is possible to output sub-categories with the “parent” attribute.

But please correct me if i am wrong.


I think, therefore I AM, … … er … I think :-?

Offline

#10 2007-10-02 13:25:55

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Multiple-level tree navigation question

Timid&friendly wrote:

i thought that it is possible to output sub-categories with the “parent” attribute.

Sure it is: <txp:category_list parent="parent-category" exclude="parent-category" /> :)
But you can’t get a third level in the navigation (articles) using that tag.

Offline

Board footer

Powered by FluxBB