Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Can't figure out Sticky and Live Scenario
OK so I can’t wrap my mind around the following scenario.
- I want to have one sticky article (output with form “A”) at the top of the page if one exists, followed by 5 live articles (output with form “B”) otherwise…
- I want to display the first of the 5 live articles (output with form “A”) followed by the next 4 articles (output with form “B”)
I can’t think of a way to do this…
Anyone?
Offline
Re: Can't figure out Sticky and Live Scenario
I can think of one method using php:
<txp:php>
$st=article(array('form'=>'A', 'status'=>'sticky','limit'=>'1'));
if ($st!='') {
echo $st;
echo article(array('form'=>'B','limit'=>'5'));
}
else {
echo article(array('form'=>'A','limit'=>'1'));
echo article(array('form'=>'B','limit'=>'4','offset'=>'1'));
}
</txp:php>
Hope this helps.
Last edited by juanjonavarro (2007-03-17 07:49:33)
Offline
Re: Can't figure out Sticky and Live Scenario
There’s a plugin that check if a tag output something or not. Using it, you could do something like :
if_output txp:article sticky limit1 form A
txp:article sticky limit1 form A
txp:article limit5 form B
else
txp:article limit5 form A
txp:article limit4 offset5 form B
Can’t remember the name of the plugin thought…
Last edited by Jeremie (2007-03-17 07:59:55)
Offline
Re: Can't figure out Sticky and Live Scenario
There is the chh_if_data plugin but it cannot be used for this case.
Offline
Re: Can't figure out Sticky and Live Scenario
Mmmh… it doesn’t have a separate conditional, yes.
Offline
Re: Can't figure out Sticky and Live Scenario
wow, france and spain to the rescue. Thanks guys, I’ll try out your solutions.
Offline
Re: Can't figure out Sticky and Live Scenario
>juanjonavarro
So I would call this on a page where I would normally place an article tag, right?
Offline
Re: Can't figure out Sticky and Live Scenario
Yes, exactly, just copy and paste this code in your page.
Of course, substitute A an B with the name of your forms.
Last edited by juanjonavarro (2007-03-17 16:41:23)
Offline
Re: Can't figure out Sticky and Live Scenario
>Hey Juan
Thanks again. Works nicely
As I’m sure I’m not the first to run into this situation, would it be worth turning this into a plugin?
-Dale
Offline
Re: Can't figure out Sticky and Live Scenario
I’m not sure. Is this a general enough situation to deserve a plugin? Can you give me a “functional description” of the desired plugin?
Offline
Re: Can't figure out Sticky and Live Scenario
Yeah, I was thinking about it some more, and I guess my general frustration comes with the need to split apart “sticky” and “live” article tags on a page to get a sticky article at the top of the page and a live list of articles following.
What I think would work better is a way to have that functionality in one tag, so that you can treat the items as one article flow.
I think what I’m actually after which is a hellava lot more involved is an article tag where status=“sticky,live” limit=“1,5” would produce 1 sticky article at the top of an article flow followed by 5 live articles in the same flow. That would have a whole lot of advantages over the two tag approach that is currently being employed.
Does that make sense? Anyone else feel this to be a limitation?
Offline
#12 2007-03-21 00:48:59
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Can't figure out Sticky and Live Scenario
That would have a whole lot of advantages over the two tag approach…
How so? How would that solve the problem of your sticky possibly not existing? It would still, in that situation, return merely 5 live articles and not the 9 desired.
Offline