Share » Learn » eZ Publish » The eZ Template Component

The eZ Template Component

Monday 17 July 2006 2:50:00 am

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

This article describes the template engine included in version 1.1 of eZ components. I analyze a simple application that, using the template engine, queries Google for specified keywords and then checks the rank of a website in the results. While I am not going to describe the entire application (which also uses the eZ PersistentObject component and some more classes), describing the template aspect of the application should give you a good idea of how the eZ Template can be used.

The models

Site

  • site: The site URI to look for in the search results.

Search

  • query: The query string to search for on Google.

Result

  • rank: Either the position of the site in the Google search results or 0 (if the site was not found).
  • timestamp: The time when the search was performed.
  • title: Either the title of the site or an empty string (if the site was not found).
  • url: Either the complete URL or an empty string (if the site was not found).
  • snippet: Either the text snippet Google displayed for the URL or an empty string (if the site was not found).

Application architecture

The application follows the MVC pattern, similar to the one described in the Image Gallery article (which described other aspects of the eZ components). There is a main controller that dispatches to several action controllers based on a URL parameter. Rather than analyzing this aspect in detail, we will look at the portion of the main controller that interacts with the template engine.

Each action controller contains the models that are needed to fill in the template variables and tell the main controller which template file to load. Specifically, we will look at the action controller that displays the detailed view of the search containing a list of the results as they are collected.

36 542 Users on board!

Tutorial menu

Printable

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

Author(s)