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

[eluser]august.gresens[/eluser]
Hello

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?

Thanks,

August
#2

[eluser]m4rw3r[/eluser]
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).
#3

[eluser]Bramme[/eluser]
You're right m4rw3r, it does share it...

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

Code:
<?php
$this->load->view('header');
$this->load->view($page);
$this->load->view('footer');
?>

And then you can make your controller look like
Code:
//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.
#4

[eluser]august.gresens[/eluser]
After searching some more, I found this info on the forums with some code to do this:

http://ellislab.com/forums/viewthread/66997/

A




Theme © iAndrew 2016 - Forum software by © MyBB