Welcome Guest, Not a member yet? Register   Sign In
Equavalent of Cake "Elements"


I'm a recent convert to CI, having abandoned the intricacies of CakePHP for something a bit more transparent.

There are a few features I miss, one being the "Elements" construct.

I'm sure there is an easy way to do the same thing in CI.

Do I just use include directives?



You can use $this->load->view(); inside another view to load subviews (or "view elements").
They share the same variables as the view that included them (I think).

You're right m4rw3r, it does share it...

What often do is create an index view file that looks like this


And then you can make your controller look like
//do lots of nifty things
$data['page'] = 'myviewfile';
$this->load->('index', $data);

All variables passed to index, will get passed to footer, header and $page.

After searching some more, I found this info on the forums with some code to do this:



Theme © iAndrew 2016 - Forum software by © MyBB