Redeem controller data in multiple views

0

I'm developing a CodeIgniter site in which all pages must have a dynamic footer with data coming from the database.

I loaded the view footer (I created a controller footer ) in the initial controller that loads a default which goes on all pages) and the contents of the initial view and worked, but the other pages do not appear.

I would like suggestions, if at all, on how to do this, how to pass data coming from a controller to various views .

Initial controller index function.

    public function index()
{

    ################### DESTAQUE ########################
    //$sql2['not_in']       =   array('field'   => 'id',    'search'    =>  $data['destaque1'][0]['id']);
    $sql1['not_secure']     =   FALSE;
    $sql1['where']          =   array(
        'status'    =>  1,  
        "arquivo != " => "''");
    //$sql1['where']            =   array('status'  =>  1,      'destaque'  =>  1,  "arquivo != " => "''", 'data_pub <= ' => "'".date("Y-m-d H:i:s")."'");
    $sql1['order']          =   array(
            'field' =>  'ci_vitrines.data',
            'hang'  =>  'DESC'
    );
    $sql1['limit']          =   3;
    // core/MY_Controller.php
    $data['vitrines']       =   $this->get_data('vitrines', NULL, $sql1);


    ################### UNIDADES ########################

    $sql2['where']          =   array(
            'status'    =>  1,
            'tipo'      =>  1
    );

    $sql2['order']          =   array(
            'field'     =>  'data',
            'hang'      =>  'DESC'
    );

    $sql2['limit']          =   14;

    $data['unidades']       =   $this->get_data('unidades', NULL, $sql2);

    ################### FRASES ASSOCIE-SE #######################

    $sql3['where']          =   array(
            'status'    =>  1
    );

    $sql3['order']          =   array(
            'field'     =>  'data',
            'hang'      =>  'DESC'
    );

    $sql3['limit']          =   4;

    $data['frases']         =   $this->get_data('frases', NULL, $sql3);

    ################### ULTIMAS NOTICIAS ########################
        /*$sql2['where']            =   array(
                'ci_noticias.status'    =>  1,
                'ci_noticias.destaque'  =>  2
        );
        $sql2['order']          =   array(
                'field' =>  'ci_noticias.data',
                'hang'  =>  'DESC'
        );
        $sql2['limit']          =   5;
        // core/MY_Controller.php
        $data['last_noticias']  =   $this->get_data('noticias', NULL,   $sql2);*/


    $this->site_template_load('layout', $this->_namemodel, $data);

}

site_template_load function

    public function site_template_load($template = '', $view = '', $view_data = array(), $return = FALSE)
{
    if($this->check_painel() === FALSE) // SITE
    {
        if(isset($_GET['versaoclassica'])) session("versaoclassica", 1);
        $viewatual = ($this->agent->is_mobile() && !session("versaoclassica")) ? "site" : "site";

        if(file_exists(APPPATH.'views/'.$viewatual.'/' . $template . '.php'))
        {
            $path_template = $viewatual.'/' . $template;
        }
        else
        {
            $path_template = 'demo/' . $template;
        }

        if(file_exists(APPPATH.'views/'.$viewatual.'/' . $view . '.php'))
        {
            $path_views = $viewatual.'/' . $view;
        }
        elseif(file_exists(APPPATH.'views/demo/' . $view . '.php'))
        {
            $path_views = 'demo/' . $view;
        }
        else
        {
            show_404();
        }
    }

    $this->template_set('contents', $this->load->view($path_views, $view_data, TRUE));
    return $this->load->view($path_template, $this->template_data, $return);
}
    
asked by anonymous 24.02.2017 / 18:45

0 answers