Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] practice with views
#4

[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">
&lt;?php echo $main_data ?&gt;
</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:
&lt;?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 => '&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;',
            );
    $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);
  }
}


Messages In This Thread
[SOLVED] practice with views - by El Forum - 12-06-2010, 02:01 PM
[SOLVED] practice with views - by El Forum - 12-08-2010, 03:46 PM
[SOLVED] practice with views - by El Forum - 12-09-2010, 02:49 AM
[SOLVED] practice with views - by El Forum - 12-09-2010, 04:47 AM
[SOLVED] practice with views - by El Forum - 12-10-2010, 10:37 AM
[SOLVED] practice with views - by El Forum - 12-10-2010, 01:17 PM
[SOLVED] practice with views - by El Forum - 12-11-2010, 02:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB