× Warning! This forum is in archival status. New contributions may not work.
How to get list of articles that has a given article as related
  • Vote Up0Vote Down mariamaria
    Posts: 38Member
    how can i  get list of articles that has a given article as related
    Thanks
  • 4 Comments sorted by
  • Hi Maria,

    try with rle="child" option

    {{ list_related_articles role="child" }}

    Not sure from which Newscoop version is this supported, I think with 4.2 and newer it should work.
    --
    Ljuba Rankovic
    Senior Front End Developer, Sourcefabric
    ljuba.rankovic@sourcefabric.org

    http://www.sourcefabric.org
    http://www.twitter.com/Sourcefabric
  • {{ list_related_articles }}
        {{ if $gimme->current_list->at_beginning }}
            <ul>
        {{ /if }}              
                <li>
                    <a href="{{ url options="article" }}">
                        {{ $gimme->article->name }}
                    </a>
                </li>
        {{ if $gimme->current_list->at_end }}     
            </ul>
        {{ /if }}                    
    {{ /list_related_articles }}
  • Vote Up0Vote Down mariamaria
    Posts: 38Member
    10x Sebastian, but what i mean is in the opposite way
    if i have article x that has y and z as related,
    how to get x using y or z

    Regards
  • Vote Up0Vote Down mariamaria
    Posts: 38Member
    10x ijuba
    but using role="child" will return only one article
    so i modified the sql query to get the whole list on
    classes/ContextBoxArticle.php line 88

                $sql = 'SELECT b.fk_article_no FROM context_boxes b'
                    . ' WHERE b.id = (SELECT c.fk_context_id '
                    . '     FROM Articles a, context_articles c '
                    . '     WHERE c.fk_article_no = ' . $params['article']
                    . '     AND a.Number = c.fk_article_no ORDER BY id LIMIT 1)';


    replace with




                $sql = 'SELECT b.fk_article_no FROM context_boxes b'
                    . ' WHERE b.id in (SELECT c.fk_context_id '
                    . '     FROM Articles a, context_articles c '
                    . '     WHERE c.fk_article_no = ' . $params['article']
                    . '     AND a.Number = c.fk_article_no ORDER BY id)';