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

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

eZ debug

Timing: Jan 18 2025 10:58:17
Script start
Timing: Jan 18 2025 10:58:17
Module start 'layout'
Timing: Jan 18 2025 10:58:17
Module start 'content'
Timing: Jan 18 2025 10:58:17
Module end 'content'
Timing: Jan 18 2025 10:58:17
Script end

Main resources:

Total runtime0.0146 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 587.9375152.6250
Module start 'layout' 0.00530.0032 740.562539.4453
Module start 'content' 0.00850.0043 780.007889.3359
Module end 'content' 0.01280.0018 869.343830.3047
Script end 0.0146  899.6484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002617.5131140.0002
Check MTime0.00128.1468140.0001
Mysql Total
Database connection0.00095.921410.0009
Mysqli_queries0.003020.578130.0010
Looping result0.00000.102710.0000
Template Total0.001510.010.0015
Template load0.00085.332810.0008
Template processing0.00074.649710.0007
Override
Cache load0.00063.842710.0006
General
dbfile0.00021.527680.0000
String conversion0.00000.040840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs