Welcome Guest, Not a member yet? Register   Sign In
Best way to avoid duplicating html in views
#11

[eluser]Polarity[/eluser]
[quote author="ericsodt" date="1229667867"]You said:
[quote author="Polarity" date="1229665461"] ..(updating only the content, would be a problem because you call a view inside the view.)...[/quote]


This is not true, you can instantiate a view and pass in true as the third argument to get the content returned. This is great for ajax calls. You can take the returned content and shove it in a <div>'s innerHTML property.

[/quote]
yea i know. thats what i used if you look at my example. but if you load a view inside a controller, and that view loads also a view, how would you seperate between a ajax call and a complete site reload with only one view file?

[quote author="ericsodt" date="1229667867"]

Secondly, I don't know why you think having a call to render a view inside a "template view" is bad coding practice. Yes, it says within the class page that views should be called from controllers, but you are. You're telling your template class to load a particular view. If you think of your view as a template then your really just calling a view from a "middle-end" controller. This may shed some light on what I mean and how it is used in the Java realm.
[/quote]
what if you want to fill complex data in the sidebar section on every site? lets say you want on every page a list of recent articles. you have to call on every controller function the model and pass the data to your view and then to the sidebar view. so you need on 10 sites 10 times the same call with the same code. you can avoid this only if you make a model call directly in the view file (whats a bad practice) or make it this way i described.


Messages In This Thread
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:50 AM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 09:31 AM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 10:24 AM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 10:35 AM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 10:46 AM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 01:10 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 01:27 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 05:44 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 06:24 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 06:24 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 06:54 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:04 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:13 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:18 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:19 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:26 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:27 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:29 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:30 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:32 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:42 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 09:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB