Welcome Guest, Not a member yet? Register   Sign In
Whi CI doesn't have Layouts implemented?
#11

[eluser]jacobc[/eluser]
[quote author="chinathong" date="1236930256"]Similar to the Rails layout, aka: content_for_layout or yield

As far as I know, CI is using include files instead[/quote]

Yea, like that...

There are some libraries people have posted that do similar things to this...

And you can pass I think the 3rd parameter as true, which means it will return the output instead of actually outputting it.
#12

[eluser]Colin Williams[/eluser]
Quote:And isn’t it discussion about things like this that helps create ideas for subsequent releases?

It's possible if the discussion is fostered in a responsible way. I just now notice that the poster's handle is "chinathong," which might suggest it's a language barrier issue (among other things).

If I seriously wanted to suggest a change to the framework, I would present a case for getting it included. X, Y, and Z frameworks have a layout component. It benefits those frameworks in a, b, and c ways. A suggestion for implementation would be how H or J contributions do it. Etc.
#13

[eluser]jacobc[/eluser]
I see how their post can be read with a harsh tone... but I don't see the point responding in that way.

It is a relevent discussion, for the discussion forum.
#14

[eluser]mihailt[/eluser]
yeah that's would be a nice feature because, i'm not really happy with constructions like
Code:
$data['header']  = $this->load->view('header','',TRUE);
$data['content'] = $this->load->view('contente','',TRUE);
$data['footer']  = $this->load->view('footer','',TRUE);
$this->load->view('layout',$data,TRUE);

but on the other hand, there always is _output function.
#15

[eluser]Colin Williams[/eluser]
Moving layout-related views loading to a parent controller (MY_Controller) opens up a lot more possibilities and flexibility.
#16

[eluser]jacobc[/eluser]
[quote author="Colin Williams" date="1236951009"]Moving layout-related views loading to a parent controller (MY_Controller) opens up a lot more possibilities and flexibility.[/quote]
I haven't really considered that approach but I like the idea...

I don't particularly like the idea of passing variables into the view for the header, footer, etc.

I was thinking you could use $protected variables in the controller to define which layout to use. Then the parent controller could somehow handle that... I might have a play around.
Could be nice to have $protected variables for which menu, layout, etc to have...
#17

[eluser]Colin Williams[/eluser]
In most layout implementations I've seen, you typically say "$x view extends $y layout and fills $z region." The Template library I wrote and use when appropriate essentially does this but maybe not in the same exact fashion. It would probably be better to let the views proclaim which layout they extend, but this would probably require a rewrite of how views are loaded (might go outside the scope of the Loader class unless you do some tricky stuff with output buffering. Not exactly sure how other frameworks approach it.)
#18

[eluser]chinathong[/eluser]
sincerely i'm not trying to put CI down ... i like CI ... i'm just asking ... sorry if it hurts :-(
#19

[eluser]xwero[/eluser]
chinathong it's not your fault the thread started with the wrong attitude.

It's possible to do almost everything you want with the functionality CI provides and a little creative thinking. It's better to stay as close to php as possible. And if you need a layout/template/partials library with all bells why not go for a good templating engine instead of using an half of the solution piece of code.
#20

[eluser]Samuurai[/eluser]
I would also like to see a layout feature.. I've only just started using CI, but it looks like I'll have to include the header and footer at the top and bottom of every view....which isn't very DRY.




Theme © iAndrew 2016 - Forum software by © MyBB