Recursive result traversal in template

Author Message

James Kessel

Sunday 10 December 2006 11:22:07 pm

Hi,

The other day I was in need of a way to traverse a resultset and present the entire result as a tree structure. Getting the data from ezPublish with fetch was a breeze, but finding a way to recursively build the tree structure was not. After som dwelling I settled with the halfbreed sollution of using a custom template operator and returning the finished result ( html and data ). This, however, seems to me as quite an inadequate sollution since I loose the ability to further manipulate the data (using other ez template operators as ezurl, wash...etc). I Guess what I was looking for was a way to define custom functions for use in ezPublish. So, the question is, Is there an easy way to define custom template functions with ez; or, is there another way to accomplish what I did with more flexibility ?

Regards,

Claudia Kosny

Wednesday 13 December 2006 2:05:15 pm

Hi James

I am not sure where the difference between a custom template operator and a custom template function is, for me they are just two names for essentially the same thing.

Without getting an example of what you were trying to achieve, it is hard to say whether there is a better solution, but generally I wouldn't return html from a custom template operator. After all I can add the html in the template.

So post an example and I'll have a look at it.

Claudia

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 21 2025 22:47:22
Script start
Timing: Jan 21 2025 22:47:22
Module start 'layout'
Timing: Jan 21 2025 22:47:22
Module start 'content'
Timing: Jan 21 2025 22:47:22
Module end 'content'
Timing: Jan 21 2025 22:47:22
Script end

Main resources:

Total runtime0.0167 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 589.1484151.2266
Module start 'layout' 0.00530.0029 740.375036.6641
Module start 'content' 0.00820.0068 777.039189.9375
Module end 'content' 0.01500.0016 866.976629.9922
Script end 0.0167  896.9688 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002414.0521140.0002
Check MTime0.00116.3237140.0001
Mysql Total
Database connection0.00106.047410.0010
Mysqli_queries0.002816.533730.0009
Looping result0.00000.078410.0000
Template Total0.00137.510.0013
Template load0.00095.610010.0009
Template processing0.00031.834910.0003
Override
Cache load0.00063.604210.0006
General
dbfile0.001710.332580.0002
String conversion0.00000.035640.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.0002 secs