Friday, June 8, 2012

Codeigniter template structure

class Pages extends CI_Controller {

  public function view($page = 'home') {

    if (!file_exists('application/views/pages/' . $page . '.php')) {
      // Whoops, we don't have a page for that!

    $data['title'] = ucfirst($page); // Capitalize the first letter

    $data['header'] = $this->load->view('templates/header', $data, true);
    $data['body'] = $this->load->view('pages/' . $page, $data, true);
    $data['footer'] = $this->load->view('templates/footer', $data, true);

    $this->load->view('templates/page', $data);



And my page.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
    <base href="<?php echo $this->config->item('base_url') ?>public/" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>CONTINUOUS IMPRESSION</title>
    <link href="css/style.css" rel="stylesheet" type="text/css" />

    <div id="container">
      <div class="main-wrapper">

        <div class="header-wrapper">
          <?php echo $header; ?>

        <div class="content-wrapper">

          <div class="content"><?php echo $body; ?></div>

          <div class="footer">
            <?php echo $footer; ?>

No comments: