CodeIgniter Forums
codeigniter views structure - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: codeigniter views structure (/showthread.php?tid=55959)



codeigniter views structure - El Forum - 11-18-2012

[eluser]Unknown[/eluser]
waht is best way to structure views?

i'm beginner


codeigniter views structure - El Forum - 11-19-2012

[eluser]ZaLiTHkA[/eluser]
[quote author="stinky" date="1353282628"]waht is best way to structure views?

i'm beginner[/quote]
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:
Code:
$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...
Code:
$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


codeigniter views structure - El Forum - 11-19-2012

[eluser]Unknown[/eluser]
thank you very much Smile