Share » Learn » eZ Publish » Understanding and developing fetch...

Understanding and developing fetch functions

Tuesday 14 September 2010 4:41:06 am

  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

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.

 

Introduction

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...

 

Pre-requisites and target population

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.

 
36 542 Users on board!

Tutorial menu

Printable

Printer Friendly version of the full article on one page with plain styles

Author(s)