Codeigniter, how to make a template -


im trying ding codeigniter mvc dont know how make template have 2 files (header , footer) , can make controllers , put information in "content" div, include top , header way this

<?php include("header.php"); ?> <div id="content">my content here</div>  <?php include("footer.php"); ?> 

hope understand mean , can me out :)

the best way load views within views.

within views/content.php:

<? $this->view('header', array('title'=>'the page title', 'keywords'=>'some keywords', 'etc'=>'...')); ?> <div id="content">my content here</div> <? $this->view('footer'); ?> 

so in controller this:

$this->load->view('content', $data); 

$data contain 'title' or 'keywords' , implemented such in controller:

$data['title'] = 'title'; $data['keywords' = 'keywords'; 

and in 'content' view:

<? $this->view('header', array('title'=>$title, 'keywords'=>$keywords)); ?> <div id="content">my content here</div> <? $this->view('footer'); ?> 

this question worded differently, identical 1 in substance: codeigniter or php equivalent of rails partials , templates


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -