[eluser]Pascal Kriete[/eluser]
::Note to self, if you type a lot - refresh::
Hey eilrahc,
There is a way to do this with a destructor, but it's not very sexy so I'll introduce you to two pretty common methods.
Template View
You can nest view loading calls, so you could create a main template:
Code:
<?php $this->load->view('header'); ?>
<div id="content">
<?php $this->load->view($content); ?>
</div>
<?php $this->load->view('footer'); ?>
And then load that every time, passing in the name of your current view:
Code:
$data['content'] = 'myviewpath';
$this->load->view('template', $data);
Template Library
Make a library to do the task for you.
Code:
class Template {
function show($view)
{
<?php $this->load->view('header'); ?>
<?php $this->load->view($view); ?>
<?php $this->load->view('footer'); ?>
}
}
You could autoload that, and then in any point of your app do $this->template->show('my/view/path')
My preferred method is somewhere inbetween. You just find something you're comfortable with.
Welcome to CodeIgniter!