php - Codeigniter loading just view? -


i've been studying codeginiter , zend couple of days , either i'm missing or there no way dynamically call view. there way make separate files header, navigation , footer , call view dynamically without calling header , footer.

every time make call page codeigniter , zend reload header , footer. big part of mvc not call same thing twice if not needed. i've been searching web , heaven't found single example of this.

this got far model:

<?php class my_loader extends ci_loader {     public function template($template_name, $vars = array(), $return =     false)     {         if($return):         $content  = $this->view('pages/templates/header', $vars, $return);         $content  = $this->view('pages/templates/navigation', $vars, $return);         $content .= $this->view($template_name, $vars, $return);         $content .= $this->view('pages/templates/footer', $vars, $return);          return $content;     else:         $this->view('pages/templates/header', $vars);         $this->view('pages/templates/navigation', $vars);         $this->view($template_name, $vars);         $this->view('pages/templates/footer', $vars);     endif;     } }  ?> 

and controler.

defined('basepath') or exit('no direct script access allowed');  class home extends ci_controller {  public function view($page = 'home') {         if ( ! file_exists(apppath.'/views/pages/'.$page.'.php'))         {                 // whoops, don't have page that!                 show_404();         }          $data['title'] = ucfirst($page); // capitalize first letter        /* defined header , footer view loaded contet         * $page argument passed url www.site.com/argument[about]         * gives content. */           $this->load->template('pages/'.$page, $data);   } } ?> 


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -