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

#13 2007-03-21 03:39:39

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

Re: Can't figure out Sticky and Live Scenario

>Mary wrote

How so?

Ok, so I think two completely independant article flows is problematic.

Let’s say I want the top article (sticky, if there is one, otherwise the first live one of the article flow) to use one form, and have all other articles in the flow use a different form. Pretty simple really, it’d just be nice to have a sticky item pop up to the top of a regular old article list.

You can’t do that with two separate (sticky/live) article tags, unless I’m mistaken.

BTW I was after 5 total articles in my example and not 9

Last edited by mrdale (2007-03-21 03:41:27)

Offline

#14 2007-03-21 05:43:43

Psilo
Member
From: Iceland
Registered: 2006-04-27
Posts: 11
Website

Re: Can't figure out Sticky and Live Scenario

Certainly the sticky and live can cause headaches when you need to display a list of X articles with Y sticky ones on top and Z live ones following. It gets even more complicated if this list is to be shown unafected by section, category or search, i.e. on pages with conditions set.

To clarify this an example might be useful, e.g. a simple web site maintaining a list of the latest 5 articles in a ‘sidebar’ showing their posted date, title and category. This ‘sidebar’ has to be shown on every page the site can display. Now for this to work, one has to build several nested conditional tags, each containing the same code for output – loads of repetition – because if for example a user browses a category then the article list will only output the articles in that particular category.

Now, if we want the to first entries in the list to be “glued”, one would expect to set their status to sticky. Wrong! This will not solve a thing, unless we add an additional <txp:article status="sticky" limit="2" /> and correct our previous tag to only output 3. But what then if there is only one article marked sticky? Yup, then our entire assemled list will only have 4 entries and not 5 as we originally intended. But that’s peanuts – it gets worse!

Lets say all these articles are in a section called, “article”, which when rendered uses a traditional article tag followed by a <txp:if_individual_article> block. Here a sticky article is not outputted, so again we’d have to add some compensation code (repetition) that checks status for sticky.

It seems rather heavy, and “sticky” seems to be a misleading word in the context of the usage guide on wiki – static would seem to be more appropriate IMHO, which leads to the end, a true status called: “pin/glue/sticky” is needed, that automatically provides the functionality of being top the list.

Sorry for cryptic way of getting to this end – hope you understand me though.


Never make the same mistake twice… there are so many… try a new one each day!

Offline

#15 2007-03-21 09:13:35

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

Re: Can't figure out Sticky and Live Scenario

I think this is just too complicated to be captured in just one plugin. You can always use custom php code (as in this case).

Offline

Board footer

Powered by FluxBB