Calling PHP methods from a template

Author Message

Mike Makris

Wednesday 13 October 2010 1:06:10 pm

I am trying to call a php method from a template in order to query the database and return an array. The parameter I pass is the ID of a ContentObject and I query for a set that is external to the ezpublish data.

My problem is that the ID I pass gets truncated to the first digit. Also, if i return a count of my result set, that number also gets truncated back in the template. Why is this happening? How do I fix it?

Finally, how do I return the array of records back into the template to print them out with a foreach loop?

Thank you

Mike

MikeM

Thiago Campos Viana

Wednesday 13 October 2010 1:24:51 pm

You could create a custom fetch function, there's a tutorial about that: Understanding and developing fetch functions

eZ Publish Certified Developer: http://auth.ez.no/certification/verify/376924

Twitter: http://twitter.com/tcv_br

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

Main resources:

Total runtime0.6040 sec
Peak memory usage4,096.0000 KB
Database Queries55

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 589.0547152.6250
Module start 'layout' 0.00670.0023 741.679739.4531
Module start 'content' 0.00900.5939 781.1328526.5078
Module end 'content' 0.60290.0010 1,307.64068.1563
Script end 0.6040  1,315.7969 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.5249160.0002
Check MTime0.00130.2110160.0001
Mysql Total
Database connection0.00120.198510.0012
Mysqli_queries0.560392.7764550.0102
Looping result0.00050.0838530.0000
Template Total0.571094.520.2855
Template load0.00200.335120.0010
Template processing0.569094.203120.2845
Template load and register function0.00010.021710.0001
states
state_id_array0.00140.238310.0014
state_identifier_array0.00120.197220.0006
Override
Cache load0.00160.2715120.0001
Sytem overhead
Fetch class attribute can translate value0.00070.118920.0004
Fetch class attribute name0.00140.228030.0005
XML
Image XML parsing0.00060.105620.0003
class_abstraction
Instantiating content class attribute0.00000.001330.0000
General
dbfile0.00130.2197160.0001
String conversion0.00000.001340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
2content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 8
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs