Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-03-17 04:08:56

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Can't figure out Sticky and Live Scenario

OK so I can’t wrap my mind around the following scenario.

  1. 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…
  2. 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

#2 2007-03-17 07:48:22

juanjonavarro
Plugin Author
From: Valencia, Spain
Registered: 2005-05-16
Posts: 485
Website

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

#3 2007-03-17 07:58:53

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

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

#4 2007-03-17 08:09:06

juanjonavarro
Plugin Author
From: Valencia, Spain
Registered: 2005-05-16
Posts: 485
Website

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

#5 2007-03-17 08:35:04

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: Can't figure out Sticky and Live Scenario

Mmmh… it doesn’t have a separate conditional, yes.

Offline

#6 2007-03-17 14:35:49

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

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

#7 2007-03-17 15:55:58

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

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

#8 2007-03-17 16:40:15

juanjonavarro
Plugin Author
From: Valencia, Spain
Registered: 2005-05-16
Posts: 485
Website

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

#9 2007-03-19 20:59:23

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

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

#10 2007-03-20 16:40:48

juanjonavarro
Plugin Author
From: Valencia, Spain
Registered: 2005-05-16
Posts: 485
Website

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

#11 2007-03-20 16:58:14

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

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

Board footer

Powered by FluxBB