Tuesday 14 September 2010 4:41:06 am
When working your eZ project, you may ask yourself a few questions :
Well, let's try to answer those vital questions ;-).
Well, that's right, the difference is thin as both can suit you in many situations. Here are significant differences :
Basically, you will need to develop a fetch function when you need to look for some data in your database, on your file system, in a partner's webservice... This is the main role for this feature, but not only. Indeed, as I said above, with fetch functions you can drastically reduce template code complexity.
Did you ever get bored of maintaining template code ? Have you ever dreamt of breakpoints driven debug instead of crappy attribute( 'show' ) ? Well, as a fetch function is written in PHP, you can transfer all your complex template code into a real function, get rid of template language limitations and take fully advantage of the real eZ Publish framework power. And of course, your fetch result can fully be exploited in your templates, so you can aggregate your data into an array, or even into PHP objects (but for that, you will need to implement some methods in your returned object's class; see the appendix for more explanations).