Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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
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
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
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
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
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
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