Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2008-06-22 16:26:44
- pritch
- New Member
- Registered: 2008-06-22
- Posts: 5
Link to oldest or newest
I’m working on creating my first site in Textpattern and I really would like a simple way to link to the first(oldest) and last(newest) articles in a section. There aren’t oldest, newest or link_to_first, link_to_last tags.
I’ve tried some plugins but nothing I’ve found does what I want. Ideally I’d like the navigation to look like this:
First Previous Next Last
Thanks
Offline
Re: Link to oldest or newest
Not tested, but something like this perhaps…
First:
<txp:php>
global $s;
$url = permlinkurl_id(safe_field('ID', 'textpattern', 'section = '.doSlash($s).' ORDER BY Posted ASC'));
echo '<a href="'.htmlspecialchars($url).'">First</a>';
</txp:php>
Last:
<txp:php>
global $s;
$url = permlinkurl_id(safe_field('ID', 'textpattern', 'section = '.doSlash($s).' ORDER BY Posted DESC'));
echo '<a href="'.htmlspecialchars($url).'">Last</a>';
</txp:php>
Last edited by ruud (2008-06-22 20:47:45)
Offline
Re: Link to oldest or newest
pritch wrote:
I’m working on creating my first site in Textpattern and I really would like a simple way to link to the first(oldest) and last(newest) articles in a section. There aren’t oldest, newest or link_to_first, link_to_last tags.
I’ve tried some plugins but nothing I’ve found does what I want. Ideally I’d like the navigation to look like this:
First Previous Next Last
Thanks
What ruud says or ob1_pagination might be of help.
Last edited by colak (2008-06-22 18:32:30)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#4 2008-06-22 20:27:35
- pritch
- New Member
- Registered: 2008-06-22
- Posts: 5
Re: Link to oldest or newest
Thanks for the response guys.
ruud, when I try to use that code I get this error:
Parse error: syntax error, unexpected T_STRING in /Applications/MAMP/htdocs/textpattern-4.0.6/textpattern/publish/taghandlers.php(2804) : eval()’d code on line 4
colak, I tried ob1_pagination and it would be perfect if I could get it to reverse order. It lists articles from newest to oldest and while it can reverse the numbering I couldn’t find a way to reverse the article order to be oldest to newest.
Offline
Re: Link to oldest or newest
Code updated in previous posting.
Offline
#6 2008-06-22 20:55:49
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Link to oldest or newest
Wouldn’t something like this work?
<txp:article sort="posted asc" form="first" limit="1" />
<txp:link_to_prev>Previous</txp:link_to_prev>
<txp:link_to_next>Next</txp:link_to_next>
<txp:article sort="posted desc" form="last" limit="1" />
Form ‘first’:
<txp:permlink>First</txp:permlink>
Form ‘last’:
<txp:permlink>Last</txp:permlink>
Offline
Re: Link to oldest or newest
You’re getting too good at this Els. You need to be careful or you might have the WP camp knocking on your door. ;)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#8 2008-06-22 23:00:08
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Link to oldest or newest
LOL why? I’m only good at tags ;)
Offline
Re: Link to oldest or newest
Shhh. Don’t tell them that. ;)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: Link to oldest or newest
I’ve used Els’ solution to some success, but there’s one problem remaining:
When a post is viewed individually (i.e. the comment form is displayed), the link to the newest/oldest post is followed by another comment form. I know this is expected behavior since I’m using <txp:article />, but is there a way I could suppress the comment form?
Lumilux – A Photoblog
Offline
Re: Link to oldest or newest
Hi Hans,
look at “Admin -> Preferences” for the auto-append comments to article and switch it to “no”.
Probably that’s what you are looking for.
Then, you will have to manually add all the comments logic to your article form.
Offline
#12 2008-07-07 20:59:12
- uli
- Moderator

- From: Cologne
- Registered: 2006-08-15
- Posts: 4,319
Re: Link to oldest or newest
If you wish to fine tune your comments and don’t know how and where to accomplish (prefs/forms/write tab), here’s an FAQ page that lists all this quite detailed, like I’d need it ;)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Link to oldest or newest
Thanks guys! Things have quite a lot since the early days, and now I’m paying the price for not upgrading sooner.
Lumilux – A Photoblog
Offline
Re: Link to oldest or newest
Directed to you Els, as I found this thread to be most appropriate for my site’s requirements, and as the bombsite says, you’re the tag master!
I have a list of all articles in a section that are sorted by title in ascending order. I also have link_to_next and link_to_previous in the article but, this resolves to articles based on their post date/time. Is it possible to have the next/previous links work in a way that it navigates through the articles as they appear in the alphabetically sorted list?
Article List:
Article 1
Article 2
Article 3
Current Article is:
Article 2
[link_to_next = Article 3 || link_to_prev = Article 2]
Cheers,
Husain
Offline
#15 2008-07-08 14:56:08
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Link to oldest or newest
husainhk wrote:
and as the bombsite says, you’re the tag master!
I wish he’d shut up for once ;) I fear I can’t answer those expectations… ;)
No native TXP tags to achieve this I think, but there is a plugin :)
Offline