suggests that you have an html page
<html> <head> <title> Hello World </title> </head> <body> <div id="menu"> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </div> <div id="main-content"> </div> <div id="footer"> Copy Right 2013 Hello World </div> </body> </html>
you could break it into 1- heading 2- menu 3- main content 4- footer
you basically put
<html> <head> <title> Hello World </title> </head> <body>
in one view called "view_header" then you put
<div id="menu"> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </div> <div id="main-content">
in a view called "view_menu" and then you put
</div> <div id="footer"> Copy Right 2013 Hello World </div> </body> </html>
in a view called "view_footer" then in your controller
$this->load->view('view_header'); $this->load->view('view_menu'); $this->load->view('YOUR_VIEW'); $this->load->view('view_footer');
Another solution I see is better: create a view called view_template_1.php
<html> <head> <title> Hello World </title> </head> <body> <div id="menu"> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </div> <div id="main-content"> <?php $this->load->view($content); ?> </div> <div id="footer"> Copy Right 2013 Hello World </div> </body> </html>
in the controller you can say that you want to call a view called About
$data = array('content'=>'about'); $this->load->view('view_template',$data);
UX Labs
source share