EllisLab text mark
Advanced Search
     
codeigniter views structure
Posted: 18 November 2012 07:50 PM   [ Ignore ]
Joined: 2012-11-18
2 posts

waht is best way to structure views?

i’m beginner

 
Posted: 19 November 2012 06:57 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2012-07-19
32 posts
stinky - 18 November 2012 07:50 PM

waht is best way to structure views?

i’m beginner

This would probably be a good place to start then: Views : CodeIgniter User Guide. smile

One idea while you’re reading through that page, I use a combination of the steps covered in ‘Adding Dynamic Data to the View’ and ‘Loading Multiple Views’.


For example, in my /views folder I have the following.

‘loadview.php’ contains:

$this->load->view('header');
if (
$page{
  $this
->load->view($page);
}
$this
->load->view('footer'); 

‘header.php’ and ‘footer.php’ contain common header / footer layout, while the $page variable attempts to load anything I pass to it from my controller. So in a controller, doing…

$data['page''welcome';
$this->load->view('loadview',$data); 

...would create HTML output that consists of ‘header.php’ + ‘welcome.php’ + ‘footer.php’. Hope that helps. smile

 
Posted: 19 November 2012 07:23 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-11-18
2 posts

thank you very much smile