Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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

#2 2008-06-22 17:02:29

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

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

#3 2008-06-22 18:31:59

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

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

#5 2008-06-22 20:48:06

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

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

#7 2008-06-22 22:35:41

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

#9 2008-06-23 15:27:52

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

#10 2008-07-07 20:42:12

Hans
Member
From: Everywhere
Registered: 2004-03-07
Posts: 99
Website

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

#11 2008-07-07 20:51:27

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#12 2008-07-07 20:59:12

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

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

Board footer

Powered by FluxBB