Master templating with CI |
[eluser]JayTee[/eluser]
[quote author="Armchair Samurai" date="1233749409"]While template libraries are nice, I find they are often overkill for many projects.[/quote] I'd have to disagree (slightly) on this assertion. In the case of the OP, he didn't want to put $this->load->view('whatever') in every single controller. If they are the same all the time, the template library suggested as a response is perfect. I prefer "views within views" myself; but I really hate calling CI functions within the view itself: Bad idea: Code: <body> I prefer this: Code: <body> The template library makes it easy to load views within views. Plus, it's VERY lightweight - so you're not adding a bunch of bulk to your code Code: $this->template->write_view('variable_name_in_view','path/to/view_file'); another good tutorial can be found here: http://codeigniter.com/wiki/MVC/
[eluser]gyo[/eluser]
Good point JayTee, loading views directly from views it's not really "clean"; but I really found this method to fit my needs. I'm a fan of simple solutions (without sacrifing quality), and since I can't really see any scary bad thing in embedding views in views I guess it's just a matter of personal taste. Anyway... it's just my point of view, and I'm willing to change my idea for a better one! Cheeers
[eluser]JayTee[/eluser]
[quote author="suashi" date="1236628105"]Anyway... it's just my point of view, and I'm willing to change my idea for a better one! [/quote]Not trying to change anyone's "view" (haha... good pun)
[eluser]gyo[/eluser]
Indeed man! It's interesting to see where we can go with this discussion, because the views (...points of view) are already marked: - If you use a Templating system (whatever it is), then the code is cleaner but with one more layer on the whole application. - If you embed views from views then the code may be dirtier, but you gain in development speed (you don't have to learn any template engine syntax etc...) and rendering time (talking about millisecond here). At this point I really think it's just about personal taste. Any thoughts?
[eluser]JayTee[/eluser]
[quote author="suashi" date="1236631625"]Indeed man! It's interesting to see where we can go with this discussion, because the views (...points of view) are already marked: - If you use a Templating system (whatever it is), then the code is cleaner but with one more layer on the whole application. - If you embed views from views then the code may be dirtier, but you gain in development speed (you don't have to learn any template engine syntax etc...) and rendering time (talking about millisecond here). At this point I really think it's just about personal taste. Any thoughts?[/quote] My personal taste = cleaner code. There's always the chance that I get hit by a bus and someone else has to maintain my application
[eluser]The Wizard[/eluser]
hello and sorry for reviving this issue, IMHO view inside a view is logically more accurate because no template engine, no matter how lightweight always skip the issue that views inside views, IF separated inside folders, are actually more then easier to use then any other system because a simple web-designer could modify or even add other parts of that file in a matter of seconds, and not bother with a templating engine AND its fare more customizable. i would prefer this->load->view. |
Welcome Guest, Not a member yet? Register Sign In |