Forums / Setup & design / limit number of words in template?

limit number of words in template?

Author Message

Dan Zembrosky

Thursday 05 June 2003 12:38:25 am

Is there any way to make it so a template only displays 150 or whatever number of words from an xml field so I can just have my article line class do that rather than requireing an intro followed by a body? It really wouild make alot more sense.

Bård Farstad

Thursday 05 June 2003 1:10:50 am

To do this you need a template operator to truncate the text after n number of words.

E.g.
{"This is my text with alot of words"|wordtrunc(4)}

The wordtrunc operator would parse the text and remove everything after the first 4 words.

PS: the wordtrunc operator needs to be written. You can use the RAD tool in eZ publish 3.1 to generate the basic class.

-bård

Documentation: http://ez.no/doc