Tuesday 14 September 2010 4:41:06 am
This tutorial will explain how template fetch functions work and how to develop custom ones. It will also show you how to call them from PHP.
When developing templates in an eZ Publish project, use of fetch functions is a recurring task. You will of course mainly fetch content nodes/objects, or maybe infos about current user :
{def $myNode = fetch( 'content', 'node', hash( 'node_id', 2 ) ) $userIsLoggedIn = fetch( 'user', 'current_user' )}
But sometimes you need to fetch pieces of information that are not covered by built-in functions (consume an external webservice, rows from non-native tables in your database, ...). Fortunately, fetch mechanism is extensible and it is fairly easy to add a new custom fetch function. Let's see how to do that...
This tutorial is targeted to intermediate eZ Publish developers or beginners who has already understood template language and eZ Publish directory structure.
Basic PHP programming skills are also needed in order to understand fetch mechanism. MVC design pattern understanding can also be useful but is not required.