[eluser]SPeed_FANat1c[/eluser]
Btw there is only one variable for all views - $data. Does is not use more memory? Let's say you make
Code:
$this->data['title'] = 'News Controller'; //set page title for view
this data is only for a header. But you pass it not only to a header view, but also to menu, content and footer views. So it means you use 4 times more memory than you actually need. Or I don't know something?
Edit:
And about the content view - this is always diferent view file. So I am thinking I could pass the main content file name to the _display() function directly. Because othervise the content view file would be something like
Code:
<div class = "main">
<?php echo $main_data ?>
</div>
and I would have to pass big ammount of data - all the html code for main content.
Edit2: to be more clear I'll show how I modified the library.
Code:
<?php
class MY_Controller extends Controller{
var $data_header;
var $data_main;
var $data_sidebar;
var $data_footer;
public function __construct(){
parent::__construct();
//default data
$this->data_header['meta'] = array(
0 => '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />',
);
$this->data_header['javascript'] = '';
$this->data_header['general'] = $this->Views_model->data_for_header();
$this->data_header['current_menu'] = 99; //for highlighting
$this->data_sidebar['general'] = $this->Views_model->data_for_sidebar();
$this->data_footer['general'] = $this->Views_model->data_for_footer();
}
/*
* pass main section view file
*/
function display($main_view){
$this->load->view('header_view', $this->data_header);
$this->load->view($main_view, $this->data_main);
$this->load->view('sidebar_view', $this->data_sidebar);
$this->load->view('footer_view', $this->data_footer);
}
}