How to exclude articles that are in a featured article list?
  • Vote Up0Vote Down haddershadders
    Posts: 26Member
    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
  • 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"


  • ... 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