Discussions
Activity
Sign In
How it works
Newscoop Themes
How to exclude articles that are in a featured article list?
Vote Up
0
Vote Down
hadders
May 2015
Posts: 26
Member
I'm trying to build a section where the first 5 articles are ordered using a featured article list and the rest are articles not in the list.
So, does anyone know how I can list_articles while excluding articles that are in the article playlist?
Thanks!
2 Comments
sorted by
Votes
Date Added
Vote Up
0
Vote Down
Jarrett
March 2016
Posts: 12
Member
I had to use a switch for this.
{{ list_articles length="20" ignore_issue="true" order="bypublishdate desc" constraints="topstory not on" }}
Switch being "topstory"
Vote Up
0
Vote Down
ljuba rankovic
March 2016
Posts: 156
Member
... or you could apply following logic: assign custom array for (let's say front page) playlist articles:
{{ $frontPL=[] }}
{{ list_playlist_articles length="5" name="Front page" }}
{{ $frontPL[$gimme->current_list->index] = $gimme->article->number }}
{{ /list_playlist_articles }}
and then just check if your article is in that list (this clause can be inside list_articles, or you can firstly geenrate new array that excludes articles already in frontPL and then output new array)
{{ $resultingArray = [] }}
{{ $i = 0 }}
{{ list_articles ignore_issue="true" order="bypublishdate desc" }}
{{ if !(in_array($gimme->article->number, $frontPL)) && ($i <= 20) }}
{{ $resultingArray[$i] = $gimme->article->number }}
{{ $i = $i+1 }}
{{ /if }}
{{ /list_articles }}
Output new array:
{{ foreach $resultingPlaylist as $value name="output" }}
{{ set_article number=$value }}
{{ if $smarty.foreach.output.first }}
<!-- for example open container -->
{{ /if }}
<h2>{{ $gimme->article->name }}</h2>
<p>{{ $gimme->article->lead }}</p>
{{ if $smarty.foreach.output.last }}
<!-- close container -->
{{ /if }}
{{ /foreach }}
--
Ljuba Rankovic
Senior Front End Developer, Sourcefabric
ljuba.rankovic@sourcefabric.org
http://www.sourcefabric.org
http://www.twitter.com/Sourcefabric
Add a Comment
Start a New Discussion
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
8,397
Sourcefabric
↳
Announcements
25
Newscoop
↳
Newscoop Support
2,189
↳
Newscoop Development
722
↳
Newscoop Security
13
↳
Newscoop Documentation
17
↳
Newscoop Themes
69
Airtime
↳
Airtime Support
3,139
↳
Airtime Development
1,286
↳
Airtime Français
146
↳
Airtime Documentation
14
↳
Airtime Hacks
102
↳
Promote your station!
37
↳
Airtime Security
11
Booktype
↳
Booktype Support
277
↳
Booktype Development
55
↳
Booktype Documentation
7
Superdesk
↳
Superdesk Development
264
↳
Web Publisher
21
Poll
No poll attached to this discussion.
Top Posters
Albert FR
1978
Martin Konecny
1860
Andrey Podshivalov
1526
Voisses Tech
1423
John Chewter
899
Daniel James
844
Roger Wilco
784
hoerich
627
Paul Baranowski
389
Cliff Wang
339