<?php
/**
 * app/plugins/blog/templates/blog.inc.php
 *
 * This is the loader for the blog template.
 *
 * @package TP Blog
 * @version 3.0
 * @author  Joey Kimsey <Joey@thetempusproject.com>
 * @link    https://TheTempusProject.com
 * @license https://opensource.org/licenses/MIT [MIT LICENSE]
 */
namespace TheTempusProject\Templates;

use TheTempusProject\Models\Posts;
use TheTempusProject\Houdini\Classes\Components;
use TheTempusProject\Houdini\Classes\Navigation;
use TheTempusProject\Houdini\Classes\Views;
use TheTempusProject\Houdini\Classes\Template;
use TheTempusProject\Bedrock\Functions\Input;

class BlogLoader extends DefaultLoader {
    /**
     * This is the function used to generate any components that may be
     * needed by this template.
     */
    public function __construct() {
        $posts = new Posts;
        Components::set('SIDEBAR', Views::simpleView('blog.sidebar', $posts->recent(5)));
        Components::set('SIDEBAR2', Views::simpleView('blog.sidebar2', $posts->archive()));
        Components::set('SIDEBARABOUT', Views::simpleView('blog.about'));
        Components::set('BLOGFEATURES', '');
        Navigation::setCrumbComponent( 'BLOG_BREADCRUMBS', Input::get( 'url' ) );
        Components::set( 'BLOG_TEMPLATE_URL', Template::parse( '{ROOT_URL}app/plugins/comments/' ) );
        $this->addCss( '<link rel="stylesheet" href="{BLOG_TEMPLATE_URL}css/comments.css">' );
        parent::__construct();
    }
}
