Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-10-01 11:12:29

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

List of 5 previous posts

Hi,

What I am trying to achieve seems to me pretty simple, but despite having combed through the forum for a good portion of last night and today, I cannot find a working solution.

In a section of my site, I’m displaying only one entry at a time. Below each entry, I am trying to list links to the 5 previous entries to that one.

Like so:

Entry text
——————-
“Previously written…”
-> Links of 5 entries directly preceding the one being viewed.

I’m welcoming any insight. Thank you!

Offline

#2 2006-10-01 12:03:41

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

Re: List of 5 previous posts

<txp:article limit="1" form="your-article-form" />
<h3>Previously written…</h3>
<txp:article_custom section="your-section" form="your-form" offset="1" limit="5" />

Offline

#3 2006-10-01 12:15:51

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

Re: List of 5 previous posts

Thank you, Skubidu. It seems to be a bit better. Although it displays the last 5 posts links in the absolute, instead of relatively to the article being viewed.

So let’s say, you’re viewing article 21, you should see links to articles 20, 19, 18, 17 and 16. And if you click to view article 20, then the “Previously written…” part displays links to entries 19, 18, 17, 16 and 15. And so on on each page.

Offline

#4 2006-10-01 13:16:50

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

Re: List of 5 previous posts

outch! okay, no I get the entire problem!
Have been thinking about it for a while and I don’t think you can do this without a plugin (and I never heard of a plugin doing this).
What about a feature or plugin request in the according forums?

Offline

#5 2006-10-01 13:37:22

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

Re: List of 5 previous posts

Alright, will do, Skubidu. In the meantime, I’ll think of a different way to organise the navigation.

Last edited by lisionosk (2006-10-01 13:39:31)

Offline

#6 2006-10-01 13:46:03

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

Re: List of 5 previous posts

Maybe you can use a tag in tag construction! I read that in the forum!

The goal is to use the result of one txp tag in another txp:tag

The goal is to get the id of the article and list the article with id-6!

Offline

#7 2006-10-01 13:54:41

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

Re: List of 5 previous posts

Hmm… would you mind precising your thought or even illustrate it with a tag example ? ;)

Offline

#8 2006-10-01 14:12:37

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

Offline

#9 2006-10-01 15:57:56

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

Re: List of 5 previous posts

That won’t help because there is no tag you could use as an attribute for article_custom that leads to the expected result.
You need to calculate the number of posts that have been made after the actual posting. The result could be used as the offset for article_custom. If you know PHP it should not be that hard to do.

Offline

#10 2006-10-01 23:02:15

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

Re: List of 5 previous posts

I’ll keep that in mind when working out something. Thanks!

Offline

#11 2006-10-01 23:27:05

jochelito
New Member
Registered: 2006-10-01
Posts: 3

Re: List of 5 previous posts

Hello,

I just recently started using Textpattern. I don’t know if this is possible: I have a plugin where I detect a given URL (not inside a textpattern tag), and in some cases, I send an image. For instance, in a form, I have:
<img src="http://www.mypage.com/GetImage?imgid=1234"/>
So if the user has the needed rights, etc, etc, I’d like to show the corresponding image.
If I simply send the image as listed here: http://www.faqts.com/knowledge_base/view.phtml/aid/621/fid/51
it works… sort of… When copying the image source in the address bar, the result is the file contents(text), instead of the image.

My plugin is sth like this:

<?php
// Detect here URI
...
// Checks
...
// If ok
openfile
read content
set headers (Content-Type, Content-length);
echo content
...
// Tag functions here
?>

I think that, after echoing the image, textpattern continues processing, and produces a 404 error.
Is there anyway to stop textpattern processing before? is this the way to go?

Thanks for your answers.

(Edit: updated to display code properly. -Mary)

Last edited by Mary (2006-10-02 03:21:11)

Offline

#12 2006-10-03 12:54:51

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

Re: List of 5 previous posts

Hi Skubidu,

we can imagin a form containing something like this:

< txp:php>
$a = article_id (array ());
for ($i = $a-1; $i >= $a-5; $i—) { echo article_custom (array( ‘id’ => $i, ‘form’ =>“myform” ));
}
< /txp:php>

do you think this could work or not?

Last edited by Dragondz (2006-10-03 12:56:12)

Offline

Board footer

Powered by FluxBB