Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2006-10-03 12:59:36

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

Re: List of 5 previous posts

Where do you get article_id from in your example?

There is one problem: You can never know if the IDs exist continuous. Maybe, there are hidden articles…

Offline

#14 2006-10-03 13:03:53

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

Re: List of 5 previous posts

That right Skubidu,

the solution exists but is not easier than we think, we can passthru the pb of non contiguous id by using an sql statement that select the 5 previous articles directly from database!

Offline

#15 2006-10-03 13:12:19

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

Re: List of 5 previous posts

What about that:

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

I’ve not tested the code, but I think it should work.

edit: forgot the section in the db call
edit2: new code
edit3: where is my head!!

Last edited by Skubidu (2006-10-04 15:35:26)

Offline

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

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,534
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

Board footer

Powered by FluxBB