How to pass a controller variable to view?

1

I need to pass the multiple $ limit to my view and display it there, how could I do that?

public function index() {
    // ....
    $this->pagination->initialize($config);
    $data['pagination'] = $this->pagination->create_links();
    $limit = $config['per_page'];
    $offset = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0; 
    $where = "id IS NOT NULL";
    $servidores = $this->server->listarServidores($this->select, $where, $limit, $offset);
    $data['servidores'] = $servidores;
    $this->template->load('template_view', 'home/home_view', $data);

}
    
asked by anonymous 24.01.2017 / 22:02

1 answer

2

As defined in the documentation of the framework, the method load , to load views and templates accepts a parameter of type array associative with values that will be present in the view / template.

Since this code is already used using the $data variable, just add the value of $limit to this array, as follows:

$data["limit"] = $limit;

In this way, the value of $limit will also be accessible in the view.

    
24.01.2017 / 22:16