Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-03-05 01:39:35

sthmtc
Member
From: CGN, GER
Registered: 2005-01-17
Posts: 586
Website

make a navigation menu from article titles (with active state)

ok here is a tricky one (at least for me):

i need to generate a navigation menu from article titles. the site will have some sections, categories are not needed.
these sections contain articles. the url scheme should be /section/title. on each section i need a list of all articles in that section as a navigation menu (now to the tricky part) and an active state should be set on the article i’m currently viewing.

so the output when viewing the article “first post” should be something like this:

<ul>
<li><a href="/section/first-post" id="active">first post</a></li>
<li><a href="/section/second-post">second post</a></li>
<li><a href="/section/third-post">third post</a></li>
</ul>

i was experimenting with ako_nav, which looks at the url to set the active state but it didn’t work out. what i did was this:

<txp:asy_wondertag><txp:ako_nav name="<txp:article form="nav_title" />" url="<txp:article_custom form="nav_url" />" /></txp:asy_wondertag>

-> nav_title:

<txp:title />,

-> nav_url:

/<txp:php>echo $GLOBALS['thisarticle']['url_title'];</txp:php>,

this creates a navigation menu on the front page but when viewing an individual article, it breaks.
anyone ever did such a thing before and can come up with a clever, maybe non-plugin solution?

any help/ideas/hints on that topic would be highly appreciated!

Offline

#2 2007-03-05 06:26:28

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: make a navigation menu from article titles (with active state)

I used $pretext[‘id’] == $thisarticle[‘thisid’].

Last edited by wet (2007-03-05 06:27:44)

Offline

#3 2007-03-05 10:47:25

sthmtc
Member
From: CGN, GER
Registered: 2005-01-17
Posts: 586
Website

Re: make a navigation menu from article titles (with active state)

you, wet, are my hero! :)
works like a charm.

Offline

#4 2007-03-05 18:19:15

anoke
Archived Plugin Author
Registered: 2006-04-15
Posts: 152

Re: make a navigation menu from article titles (with active state)

There’s also <txp:page_url type="id"/> for $pretext[‘id’].


- When chickens are cold, they roost in trees; when ducks are cold, they plunge into water -

Offline

Board footer

Powered by FluxBB