Skip to content

Instantly share code, notes, and snippets.

@cjbell
Created February 1, 2012 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjbell/1716759 to your computer and use it in GitHub Desktop.
Save cjbell/1716759 to your computer and use it in GitHub Desktop.
Codeigniter template for Lee
<?php
// Controller (method)
class Base extends CI_Controller {
function index(){
$data = array(
'page' => 'home',
'view' => 'pages/base/index.php'
);
$this->load->view('templates/base.php', $data);
}
function contact(){
$data = array(
'page' => 'contact',
'view' => 'pages/base/contact.php'
);
$this->load->view('templates/base.php', $data);
}
}
?>
<?php
// Template file (base.php)
// You need to autoload the URL helper to use site_url and base_url
?>
<header>
<h1>Logo</h1>
<ul>
<li><a href="<?php echo site_url('base/')?>" class="<?php echo ($page == 'home') ? 'sel' : ''; ?>">Home</a></li>
<li><a href="<?php echo site_url('base/contact')?>" class="<?php echo ($page == 'contact') ? 'sel' : ''; ?>">Contact</a></li>
</ul>
</header>
<div>
<?php echo $this->load->view($view); ?>
</div>
<footer></footer>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment