CodeIgniter Forums
header/footer - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Best Practices (https://forum.codeigniter.com/forum-12.html)
+--- Thread: header/footer (/thread-66718.html)



header/footer - eagle00789 - 11-24-2016

I am currently building my app using the great codeigniter framework, but i find 1 thing a bit annoying.
Every time i load my views, i also need to loead my header and footer views. Is there any way to always load those 2 views before and after my custom view?

Curently i use the below code to load my own view surrounded by myheader and footer:


PHP Code:
            $this->load->view('templates/header'$data);
            
$this->load->view('templates/menu'$menu);
            
$this->load->view('about/create_change'$data);
            
$this->load->view('templates/footer'); 



RE: header/footer - ciadmin - 11-24-2016

You might draw some inspiration from https://github.com/bcit-ci/codeigniter-website ... specifically the view templating, in the base controller & it's render().


RE: header/footer - rupamhazra - 11-25-2016

(11-24-2016, 03:22 PM)eagle00789 Wrote: I am currently building my app using the great codeigniter framework, but i find 1 thing a bit annoying.
Every time i load my views, i also need to loead my header and footer views. Is there any way to always load those 2 views before and after my custom view?

Curently i use the below code to load my own view surrounded by myheader and footer:


PHP Code:
            $this->load->view('templates/header'$data);
            
$this->load->view('templates/menu'$menu);
            
$this->load->view('about/create_change'$data);
            
$this->load->view('templates/footer'); 

@eagle00789
if i understood what you said then you can try like this 
public function header()
{
  $this->load->view('templates/header', $data);
}

public function footer()
{
  $this->load->view('templates/footer');
}

these two function you can declare on constructor.
whenever your controller load the header and footer automatically loaded.


RE: header/footer - BabalooAye - 11-26-2016

(11-24-2016, 03:22 PM)eagle00789 Wrote: I am currently building my app using the great codeigniter framework, but i find 1 thing a bit annoying.
Every time i load my views, i also need to loead my header and footer views. Is there any way to always load those 2 views before and after my custom view?

Curently i use the below code to load my own view surrounded by myheader and footer:


PHP Code:
            $this->load->view('templates/header'$data);
            
$this->load->view('templates/menu'$menu);
            
$this->load->view('about/create_change'$data);
            
$this->load->view('templates/footer'); 

This works fine for me: http://jeromejaglale.com/doc/php/codeigniter_template