Welcome Guest, Not a member yet? Register   Sign In
Use of Closures in Views
#5

Don't see anything wrong with that personally. Then again, if I only needed a helper function on a single view, I've been known to create the function at the top of the view file and completely break the separation that should be there. Smile

My tact lately, is a heavier use of objects. In a project I'm working on currently, I have a Album class that does nothing except represent a single album of music. It does, however, have a few helper methods like  image() and imageURL().  

When the model returns the $list (from your example) it returns an array of Track instances. These are passed directly to the view. Then, in the view, I just have to call the imageURL() method. It's not quite the same thing you've done here, but pretty close in concept, since it will provided a default image if none exists.
Reply


Messages In This Thread
Use of Closures in Views - by mwhitney - 09-09-2015, 09:25 AM
RE: Use of Closures in Views - by includebeer - 09-12-2015, 10:25 AM
RE: Use of Closures in Views - by mwhitney - 09-14-2015, 10:15 AM
RE: Use of Closures in Views - by PaulD - 09-15-2015, 03:37 PM
RE: Use of Closures in Views - by kilishan - 09-16-2015, 06:31 AM
RE: Use of Closures in Views - by jLinux - 09-21-2015, 03:28 PM
RE: Use of Closures in Views - by spjonez - 09-24-2015, 06:57 AM
RE: Use of Closures in Views - by mwhitney - 09-24-2015, 07:29 AM
RE: Use of Closures in Views - by kilishan - 09-24-2015, 07:20 AM
RE: Use of Closures in Views - by spjonez - 09-24-2015, 03:42 PM
RE: Use of Closures in Views - by mwhitney - 09-25-2015, 10:03 AM
RE: Use of Closures in Views - by jLinux - 09-25-2015, 06:46 AM
RE: Use of Closures in Views - by mwhitney - 09-25-2015, 10:29 AM
RE: Use of Closures in Views - by kilishan - 09-25-2015, 07:04 AM
RE: Use of Closures in Views - by jLinux - 09-25-2015, 07:12 AM
RE: Use of Closures in Views - by jLinux - 09-25-2015, 07:17 AM
RE: Use of Closures in Views - by kilishan - 09-25-2015, 07:32 AM
RE: Use of Closures in Views - by jLinux - 09-25-2015, 08:13 AM
RE: Use of Closures in Views - by mwhitney - 09-25-2015, 08:26 AM
RE: Use of Closures in Views - by spjonez - 09-25-2015, 11:00 AM
RE: Use of Closures in Views - by mwhitney - 09-28-2015, 10:51 AM
RE: Use of Closures in Views - by kilishan - 09-25-2015, 01:24 PM



Theme © iAndrew 2016 - Forum software by © MyBB