Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2006-10-03 13:25:01

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

Re: List of 5 previous posts

I think it should works too,

if I have time i will test it, maybe lisionosk will do the test!

Another pb solved by the forum yeeaah ;)

Offline

#17 2006-10-03 13:47:53

lisionosk
Member
From: Switzerland
Registered: 2006-02-10
Posts: 99

Re: List of 5 previous posts

Sure, I will be glad to test it. So I just paste the above where I want my five links to be and replace ‘your-section’ and ‘your-form’ ?

Thank you for working your head around it, I’m sure this will be useful to other people as well.

PS. Would it work for photoblogs, too ? A hack or a plugin to implement this in photoblogs templates would be awesome, I think.

Offline

#18 2006-10-03 15:03:22

Skubidu
Archived Plugin Author
Registered: 2004-10-23
Posts: 611
Website

Re: List of 5 previous posts

So I just paste the above where I want my five links to be and replace ‘your-section’ and ‘your-form’ ?

Yes.

Offline

#19 2006-10-04 13:57:30

lisionosk
Member
From: Switzerland
Registered: 2006-02-10
Posts: 99

Re: List of 5 previous posts

So, I pasted the code, customised the two fields, and I get this message when loading the page:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/urbangr1/public_html/textpattern/publish/taghandlers.php(1726) : eval()’d code on line 4

I’m not sure what I should look at, as I don’t know PHP.

Offline

#20 2006-10-04 15:17:06

Skubidu
Archived Plugin Author
Registered: 2004-10-23
Posts: 611
Website

Re: List of 5 previous posts

I updated the code above. Can you try it again?

Offline

#21 2006-10-04 15:29:26

lisionosk
Member
From: Switzerland
Registered: 2006-02-10
Posts: 99

Re: List of 5 previous posts

The error message disappeared. I wasn’t sure what to replace ‘your-article’ with, though. The section is named ‘journal’ and the form ‘previous-list’. I tried ‘journal’, but no link appeared. This is what I pasted:

<code><txp:php> global $thisarticle; $my_section = ‘journal’; $pre_count = safe_count(“textpattern”, “`ID` >= “.$thisarticle[‘thisid’].” AND `Section` LIKE ‘”.$my_section.”’”); echo article_custom(array(‘form’ => ‘previous-list’, ‘section’ => $my_section, ‘limit’ => ‘5’, ‘offset’ => $pre_count));</txp:php> </code>

The closing txp:php tag is included, it just gets cut off here for some reason…

Last edited by lisionosk (2006-10-04 15:31:24)

Offline

#22 2006-10-04 15:41:16

Skubidu
Archived Plugin Author
Registered: 2004-10-23
Posts: 611
Website

Re: List of 5 previous posts

You’re right: it should have been 'your-section' and not 'your-article'. So the code you’re using looks right (some quotes doen’t – is it because of Textile in this forum?). I tried the code on a test page and it worked. Do you get any errors, warnings, messages?

This is how your code should look like:

<txp:php>
  global $thisarticle;
  $my_section = 'journal';
  $pre_count = safe_count("textpattern", "`ID` >= ".$thisarticle['thisid']." AND `Section` LIKE '".$my_section."'");
  echo article_custom(array('form' => 'previous-list', 'section' => $my_section, 'limit' => '5', 'offset' => $pre_count));
</txp:php>

PS: Use bc.. to post blockcode.

Offline

#23 2006-10-04 15:52:18

lisionosk
Member
From: Switzerland
Registered: 2006-02-10
Posts: 99

Re: List of 5 previous posts

The section name is correct; the form does exist and contains:

<code><txp:permlink><txp:title /></txp:permlink> <txp:posted format=”%d.%m.%y” /><br /></code>

But nothing appears and I get no warning messages.

Last edited by lisionosk (2006-10-04 19:44:22)

Offline

#24 2006-10-04 18:40:36

Skubidu
Archived Plugin Author
Registered: 2004-10-23
Posts: 611
Website

Re: List of 5 previous posts

In which context do you use the code? It needs to be in an article form to work the way it is now.
If you need it outside an article form, it has to be adjusted.

Last edited by Skubidu (2006-10-04 18:50:36)

Offline

#25 2006-10-04 19:44:04

lisionosk
Member
From: Switzerland
Registered: 2006-02-10
Posts: 99

Re: List of 5 previous posts

I see, it was my mistake, I had placed the code in a Page template. I moved it to the article form and it works now, exactly as I wanted it to. Great job, Skubidu, and thanks a lot for your effort. I hope other people can find the thread when they need something like this. Enjoy your evening!

:)

Offline

#26 2006-10-16 22:51:41

wordgasm
Member
Registered: 2006-05-17
Posts: 83
Website

Re: List of 5 previous posts

can that work not only with previous but with newer article links as well? for instance viewing the latest article with the ID 30 will show the past four articles 29, 28, 27, 26, but viewing article, say, 26 will show links to article 28, 27, 25, 24. Similarly, viewing article 1 will give the article links 5, 4, 3, and 2, such that whatever article you’re viewing you’ll always see four article links nearest to that article… is that possible?

Last edited by wordgasm (2006-10-16 23:08:07)

Offline

Board footer

Powered by FluxBB