<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}

class Slider_site extends MX_Controller
{

    public function index($code)
    {
        $this->load->model('slider/slider_tmodel');
        $this->load->model('slider/slide_tmodel');

        $slider = $this->slider_tmodel->fetch_by_code($code);

        if (empty($slider['id_slider'])) {
            show_error(sprintf('Slider with code %s not found', $code));
        }

        $content = [
            'items' => $this->slide_tmodel->fetch_all_by_code($code),
        ];

        return $this->parser->parse($slider['template'], $content, TRUE);
    }

}
