Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2009-05-26 00:38:56
- parlour
- Member
- From: Germany
- Registered: 2006-09-01
- Posts: 20
turn menu links into plain text when viewing the respective page
We are in the process of building a very static 10-page-website (20 if translated pages are included), and we plan on manually building a menu that links to the 10 pages (if there is a better less manual solution, please tell me – I didn’t find any, and since the website is so small it doesn’t really matter, but I wonder how you would go about building bigger mostly static websites with textpattern without having to dabble with manually building a menu).
If the user is viewing a certain page I want the menu entry to lose its a-tag (because of that I can also style it differently).
I know how to do that with conditional tags, problem is: that really blows up the amount of stuff you have to write (10*2*2=40 conditional tags around all the different a-open-and-close-tags).
e.g.
<txp:if_article_id id="1,2,3,4,6,7,8,9,10">
<a href="?id=5">
</txp:if_article_id>
Fifth Menu Entry
<txp:if_article_id id="1,2,3,4,6,7,8,9,10">
</a>
</txp:if_article_id>
And now repeat that for all other menu entries.
Is that really the most elegant solution?
Last edited by parlour (2009-05-26 00:39:14)
Offline
Re: turn menu links into plain text when viewing the respective page
I think this is what you want:
<txp:article_custom id="1,2,3,4,6,7,8,9,10" sort="ID asc">
<txp:hide>
If the user is viewing the article, just display the title. Otherwise, link to it.
</txp:hide>
<txp:if_article_id>
<txp:title/>
<txp:else/>
<txp:permlink>
<txp:title/>
</txp:permlink>
</txp:if_article_id>
</txp:article_custom>
Offline
#3 2009-05-26 02:12:28
- parlour
- Member
- From: Germany
- Registered: 2006-09-01
- Posts: 20
Re: turn menu links into plain text when viewing the respective page
Great! Thank You! Somehow I only ever think of the complicated solutions.
Just one thing (I asked this question a bit prematurely, our textpattern installation is not yet actually up and running, so I cannot yet test): can article_custom have a custom (manual!) sort order? I know that I already used article_custom to display three articles on a page and since I didn’t find a way to sort the articles in any custom way (I could rely on post date or article id but what if I wanted to arbitrarily change the order on the page?) I used a custom field and gave them numbers (1, 2 and 3) and simply sorted this field.
Is there an easier solution to that or are custom fields the way to go? Seems to me like another clumsy solution that is not really all that elegant. Sorry for getting a bit off topic.
Offline
Re: turn menu links into plain text when viewing the respective page
If you want to arbitrarily change the order, check out stm_article_order and change sort
to sort="position asc"
.
Offline