Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-05-10 09:31:29

douglgm
Member
From: Bristol
Registered: 2006-08-23
Posts: 182
Website

List of recent articles from more than one section

I’m sure this has been asked many times before, but I’ve not found anything with the search.

I need to generate a list of the latest 5 articles from more than one section?

Both the recent_articles and article_custom tags enable you to restrict the results to an individual section.

How can I do this?

Offline

#2 2007-05-10 09:44:51

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

Re: List of recent articles from more than one section

hi Doug
Maybe this could be of help

<ul><txp:article limit="5" form="latest5" /></ul>

the latest5 form could look something like this

<li><txp:permlink><txp:title /></txp:permlink></li>


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2007-05-10 11:03:28

douglgm
Member
From: Bristol
Registered: 2006-08-23
Posts: 182
Website

Re: List of recent articles from more than one section

Thanks for the help, but I was aware of that.

What I meant was that I need to display a list of the most recent 5 articles from two of many sections. The problem I have is that the sections=”“ attribute is only looking for a single value and not a comma separated list of sections!

If I use <txp:recent_articles section=“section4”> I get a list of recent articles in section 4.

If I try section=“section4, section8” for example – I get nothing.

(Same goes for article_custom)

Doug.

Offline

#4 2007-05-10 11:04:55

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: List of recent articles from more than one section

Currently, you need a plugin to do this.
Showing the last 5 items isn’t a problem. Neither is showing articles from a few sections only. The problem is that combining both of these requirements cannot be done with the standard TXP tags (at least not that I know)

Offline

#5 2007-05-10 11:33:02

douglgm
Member
From: Bristol
Registered: 2006-08-23
Posts: 182
Website

Re: List of recent articles from more than one section

I had a horrible feeling someone was going to say that!

It’s frustating that all too often the functionality you’d expect just isn’t quite there!

Thanks Ruud.

Offline

#6 2007-05-10 11:56:12

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: List of recent articles from more than one section

try chh_article / chh_article_custom to pull in articles from several sections.


TXP Builders – finely-crafted code, design and txp

Offline

#7 2007-05-10 16:54:01

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: List of recent articles from more than one section

And then there is the workaround using if_article_section in the article form. It’s doable when you need only 2 sections:

<txp:if_article_section name="section1">
your code here
</txp:if_article_section>
<txp:if_article_section name="section2">
exactly the same code here
</txp:if_article_section>

Ah well… not perfect but it’s something.

Offline

#8 2007-05-10 17:13:19

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: List of recent articles from more than one section

Els, that doesn’t work, because he wants to show exactly 5 articles. Jakob’s suggestion to use chh_article_custom is probably the easiest way to do it without using <txp:php> tags.

Offline

#9 2007-05-10 18:46:14

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: List of recent articles from more than one section

Ruud, of course the plugin is easier! But why wouldn’t he be able to show 5 articles: <txp:article_custom form="my_example" limit="5" />.

Offline

#10 2007-05-10 20:57:56

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: List of recent articles from more than one section

Suppose that gives him articles from respectively: section1, section2, section3, section1, section2.
And let’s assume he only wants to show section1 and 2 articles. Using your trick, he’d only see 4 articles, instead of 5, because the selection on section happens after the article tag has generated the list of 5 articles.

Last edited by ruud (2007-05-10 20:58:29)

Offline

#11 2007-05-10 22:08:04

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: List of recent articles from more than one section

(Och verhip!) Yes I can see that now, don’t know why I didn’t think about that. Thanks for explaining!

Offline

#12 2007-05-11 07:48:53

douglgm
Member
From: Bristol
Registered: 2006-08-23
Posts: 182
Website

Re: List of recent articles from more than one section

Yes, I need the most recent articles from multiple sections in reverse date order. sigh

You know how it is. You’ve got everything working on a frankly stunning intranet powered by Textpattern. The “customer” comes up to me and asks if I can add something. It sounds SO simple that I respond that of course I can, and that with the power and flexibility of Textpattern it’ll take me but a few moments!

…a few moments later you then realise that things aren’t going to be quite so simple and it’s a frantic few hours scrabbling around Textbook, the forums and then hunting for a plugin that can cover your backside.

Don’t get me wrong – I still love Textpattern. It’s just I have an increasingly long list of “if only txp did..” items!

Much credit and many thanks to all the active forum members who go out of their way to help the frustrated and the desperate like myself!

Offline

Board footer

Powered by FluxBB