Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2007-03-05 06:01:23
- resplence
- Member
- Registered: 2006-03-07
- Posts: 37
Comics style navigation
I’ve been using my free time in the past couple days to work on my comics site, mostly trying to get the navigation just right. In the forum I’ve seen a few other people also trying to set up a comics site and if I recall correctly they were also having trouble with the navigation.
It seems comics sites or toonblogs are becoming increasingly popular, so I just thought of sharing my solution to the trademarked comics-style navigation in case someone else ever needs a place to get started. I know a post like this would’ve saved me many hours :)
In my site I use first | previous | next | latest
. Textpattern already supplies previous (<txp:link_to_prev>
) and next (<txp:link_to_next>
) tags, but first and latest might be tricky. This is how I did it:
first
<txp:article_custom form="link_to_first" limit="1" section="comics" sort="Posted asc" />
latest
<txp:article_custom form="link_to_latest" limit="1" section="comics" sort="Posted desc" />
Each line displays only 1 article from the comics section, the first one in both chronological sorting directions (posted ascending and posted descending), which will be, naturally, the first and the latest posts.
I also had to create two forms that are the actual content displayed on the menu:
link_to_first
<txp:permlink>first</txp:permlink>
link_to_latest
<txp:permlink>latest</txp:permlink>
Now, for the sake of uniformity, I like the navigation links to be visible at all times. When there are no previous or next posts, those links become inactive automatically. However, the links for first and latest were always active, which could be confusing for visitors.
If they click to see the first post, and when the page reloads the link to the first post is still there, they might spend a moment thinking something like “I thought I already was on the first post”, and/or think it’s some sort of bug. I did not want that.
I tried to figure out how I could use some of TXP’s conditional tags to render these links inactive (text only) “automatically”, but I think it just can’t be done. So I resorted to creating two categories, first and latest, and used if_article_category
to do the work. This is not really automatic because I have to edit the previous post and remove its category in order for the link to the current latest post to become active again, while viewing that article. But this isn’t so bad. This is the actual code:
first
<txp:if_article_category name="first" number="1">
first
<txp:else />
<txp:article_custom form="link_to_first" limit="1" section="comics" sort="Posted asc" />
</txp:if_article_category>
latest
<txp:if_article_category name="latest" number="1">
latest
<txp:else />
<txp:article_custom form="link_to_latest" limit="1" section="comics" sort="Posted asc" />
</txp:if_article_category>
Alright. The only problem now is that, on the frontpage, the link to the latest post is still active. This, of course, is a blatant contradiction to the inactive next link, and would get everyone clicking it to see what’s this latest post stuff. So I used if_section
to recognize the frontpage and render it inactive. At first I feared the nested conditionals would break it all up, but to my surprise it worked perfeclty.
latest – final
<txp:if_article_category name="latest" number="1">
latest
<txp:else />
<txp:if_section name=",">
latest
<txp:else />
<txp:article_custom form="link_to_latest" limit="1" section="comics" sort="Posted desc" />
</txp:if_section>
</txp:if_article_category>
So there you have it. If anyone has any corrections or knows how to achieve these results with less or better code, please let me know. I still wish I didn’t have to manually edit a previous article everytime I post a new one, but I can totally live with it.
I hope this is of any help for anyone out there.
(Also, please excuse my english, I’m not a native speaker.)
Last edited by resplence (2007-03-05 06:05:16)
Offline
#2 2007-03-06 01:26:43
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Comics style navigation
(singing, to the tune of It Was A Very Good Year) The WIKI, it is a verrrry good thing…
Offline
#3 2007-03-06 16:48:34
- resplence
- Member
- Registered: 2006-03-07
- Posts: 37
Re: Comics style navigation
Oh, is it good enough for the WIKI? I was actually expecting some corrections or improvements. I’m gonna put it there soon, then.
Last edited by resplence (2007-03-06 16:48:44)
Offline
#4 2007-03-06 21:32:33
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Comics style navigation
Sure, why not? :)
The thing about the WIKI is that it makes managing corrections nicer, and it’s at a permanent location as opposed to buried in the forum. :)
Offline
Re: Comics style navigation
resplence,
Great site! Keep up the great work!
Offline
#6 2007-04-25 06:35:39
- resplence
- Member
- Registered: 2006-03-07
- Posts: 37
Re: Comics style navigation
Thanks, Christopher.
Unfortunately I haven’t had the time to do anything remotely fun-related lately, and the site will have to go on hiatus soon.
Mary, I still haven’t had the time to turn that into wiki material. I’m sorry.
Offline
Pages: 1