Welcome Guest, Not a member yet? Register   Sign In
Build page function
#2

[eluser]Jelmer[/eluser]
Just build a wrapper view that you load and pass any specific demands in variables which you process either directly into the view function or with switch statements. And load all the extra views from there.

Like this in your controller
(and putting al previously set options for the $data array in a key of the array and adding the page-type so you can pass the rest of the $data array into the views):
Code:
$data = array('data' => $data);
$data['page'] = 'events/view';
$this->load->view('admin/wrapper', $data);

And put this in your wrapper.php
Code:
$this->load->view('admin/header', $data);
$this->load->view('admin/top_message');    
$this->load->view('admin/left_panel');    
$this->load->view('admin/'.$page, $data);
$this->load->view('admin/footer');

I use this extensively as I use templates: the template's wrapper is loaded and checks if any specific views are available for the template (though in reality I made a view-wrapper function that does the checking as I didn't want to rewrite it for every partial view, it also checks if the default exists and produces a non-fatal error if not)
Code:
if (file_exists(APPPATH.'views/'.$template.'/'.$content_type.'.php'))
          $this->load->view($template.'/'.$content_type);
and if not loads the default template.
Code:
else $this->load->view('default/'.$content_type);


Messages In This Thread
Build page function - by El Forum - 11-18-2008, 06:32 AM
Build page function - by El Forum - 11-18-2008, 08:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB