Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

Template function

{si-block}function

In order to have SI-blocks generated in your HTML file, you need to call a new template function: si-block.

Use the following syntax:

{si-block key=string $key [ttl=integer $ttl]}
your template code here
{/si-block

 

The "key" attribute is mandatory and can be a scalar or an array. You can not use objects as keys. You can use a hash if you want, but note that then no key will be taken into account. The "ttl" is optional. However, if you plan to use ESI and Akamai, it is recommended to use the "ttl".
You can choose between 4 units :

  • h (hours)
  • m (minutes)
  • s (seconds)
  • d (days)

Specifying a floating point time is syntactically correct, however the extension will convert it into an integer at runtime. This means that e.g. setting "ttl=9.5h" will not create any syntax error but the TTL that will be used is 9h.
You can put any template code between {si-block} instructions. The template code inside these blocks will be interpreted and stored into a static HTML file.

Key generation

At a lower level the key for each block is composed by the following information:

  • value of the "key" attribute
  • location of the {si-block} call in the template
  • template name
  • siteaccess name
  • view parameters

This means that there is no need to think about uniqueness in your keys, because everything is already done in the template function. Although it is not recommended, it is even possible to use the same key in the same template but at different locations in the file. In this case the final key will be different. Keep in mind that this will make the template more difficult to maintain.

Important notes

{si-block} vs {cache-block}

SI blocks do not replace cache-blocks since there is neither subtree_expiry nor a complex key system.

Personalized pages

It is not possible to use SI blocks for personalized pages. If you do this all user will see the same page.

Ester Heylen (23/03/2010 12:21 pm)

Ester Heylen (23/03/2010 12:25 pm)


Comments

There are no comments.