Creating custom template (operators of functions)

Creating custom template (operators of functions)

Friday 14 November 2003 8:45:38 am - 2 replies

Author Message

Nicklas Lundgren

Friday 14 November 2003 9:12:24 am

Hi,
Im not sure that you can make a template operator that takes more than one param.
However I used the php function shuffle(array) instead of rand. Since it only takes one param its easy to make the template operator.

Shuffle is good for instance if you want to select a random article. Then you can fetch articles to an array and run your template operator shuffle on it, like:

$myArticle=$arrMyArticles|shuffle

This will give you one of the articles (randomly selected).

Of course, this only replaces the need for random numbers in certain cases.

Anyhow, hope this helps.

Regards,
Nicklas

Paul Borgermans

Friday 14 November 2003 11:22:28 am

Indeed, the template.ini operators can only map to functions that take 1 argument. If you need more, you will have to write a new template operator as an extension. It is not so difficult: take a look at the contributions and the RAD tool in the admin interface.

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

You must be logged in to post messages in this topic!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.