Pages

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!
      show_404();
    }

    $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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <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" />
  </head>

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

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

        <div class="content-wrapper">

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

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

Wednesday, June 6, 2012

Taxonomy add edit form simplified for client

I wanted to clean the taxonomy form for our client.

So i created one custom module. and here is my module file code.

function capo_form_alter(&$form, &$form_state, $form_id){
  switch ($form_id) {
    case 'taxonomy_form_term':
      $form['name']=$form['identification']['name'];
      $form['parent']=$form['advanced']['parent'];
      $form['parent']['#weight']=1;
      $form['submit']['#weight']=10000;
      if($form['delete'])
      $form['delete']['#weight']=10001;
      $form['weight']=$form['advanced']['weight'];
      $form['weight']['#access']=FALSE;
      $form['parent']['#multiple']=0;
      $form['parent']['#size']=1;

      unset ($form['identification']);
      unset ($form['advanced']);
      //dsm($form);
      break;

    default:
      break;
  }
}