<?php
$path = '../../../';
require_once $path . 'core/includes/header.inc.php';

$cats = ['' => '--Select Article--'];


if(config('app.env') == 'staging') {
    $listings_page_id = 176;
}else{
    $listings_page_id = 130;
}

$page = new Page($listings_page_id);

$articles = [];
$articles[0] = '--Select Listing--';

if(!empty($_GET['json_articles']) && !empty($_GET['category'])) {




    $article_filter[] = array("Category", $_GET['category'], "=", "varchar", "group_check");

    // Set up listing
    $specialiat_articles = Listing::newInstance($listings_page_id)
                                  ->setOrder([["Publish Date", "DESC", "datetime"]])
                                  ->setCurrentPage(null)
                                  ->setFilter($article_filter)
                                  ->run();

    $specialiat_articles->getListing();
    $specialiat_articles->getPagination($twig);


    foreach($specialiat_articles->list as $article) {
        $articles[$article->id] = $article->title;
    }

}

header('Content-Type: application/json');
echo json_encode($articles);
die();




