<?php

// Find relevant articles
$news_container_page_id = 25;

$recommend_count = 4;
$recommended_articles = [];


if (count($recommended_articles) < $recommend_count) {
    $remainder = $recommend_count - count($recommended_articles);
    $news_filter = [];
    $news_filter[] = "pages.id != '" . $p->id . "'";
    $articles = Listing::newInstance($news_container_page_id)
        ->setLimit($remainder)
        ->setOrder([array("Publish Date", "DESC", "datetime")])
        ->setFilter($news_filter)
        ->run();
    $articles->getListing();
    $recommended_articles = CmsHelper::mergeArticles($recommended_articles, $articles->list);
}

$twig->addGlobal('recommended_articles', $recommended_articles);
