3.2 explode operator

Author Message

Paul Forsyth

Thursday 11 September 2003 7:39:45 am

Im playing with the new template operators in 3.2 and have become a little stuck with 'explode'.

I was of the opinion that i could let through php functions via the template.ini file, then i noticed the lib file 'eztemplatearrayoperator.php' has the explode operator defined within it. But i can't seem to get it to work. Im trying to use similar syntax as the php function but all i seem to get are array_slice errors...

For example:

{let test="explode,test"|explode(",")}
{section loop=$test}
Item is:{$:item}
{/section}
{/let}

This gives the error:

array_slice(): The first argument should be an array in /var/www/html/3_2/lib/eztemplate/classes/eztemplatearrayoperator.php on line 441

I think i must be using the operator in a wrong way. How do i use it?

Paul

Gunnstein Lye

Thursday 11 September 2003 9:05:59 am

The explode operator is for arrays, not strings. Use it to split an array into two arrays. The input value must be an array, and the argument is an integer which specifies the split point. It returns an array containing the two resulting arrays.

It seems you have to use the template.ini approach.

Paul Borgermans

Thursday 11 September 2003 10:40:32 am

So the docs are wrong?

http://ez.no/developer/ez_publish_3/documentation/development/libraries/ez_template/operators/array_handling

-paul

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

Bruce Morrison

Thursday 11 September 2003 3:57:57 pm

After having a look at the code, the explode operator takes an offset and returns 2 arrays. The first array is an array of elements up to the offset and the second is the elements from the offset to the end. This is quite different to what is documented (as Paul has pointed out)

The documentation at http://ez.no/developer/ez_publish_3/documentation/development/libraries/ez_template/operators/array_handling indicates that many of the functions should be able to take both arrays and strings. From looking at the code at lib/eztemplate/classes/eztemplatearrayoperator.php this is not the case.

I think it is an excellent idea to produce documentation before the coding is done. That way it's done and the coders have something to work off and we don't end up in the situation where we are now (limited documentation).

One can only assume that these functions will be completed before the final release.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Gunnstein Lye

Friday 12 September 2003 1:48:14 am

Yes, it seems the docs are wrong. I'll bug the others about this, we'll get it fixed before the release or change the docs.

Gunnstein Lye

Friday 12 September 2003 3:00:50 am

It was fixed yesterday, in fact. String support for explode has been added to svn and will be in the release. I'll see to that the docs are updated.

Paul Forsyth

Friday 12 September 2003 3:39:53 am

Lovely. Thanks.

Paul

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

Main resources:

Total runtime1.0970 sec
Peak memory usage4,096.0000 KB
Database Queries73

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0044 588.9453152.6094
Module start 'layout' 0.00440.0026 741.554739.4141
Module start 'content' 0.00701.0885 780.9688663.8594
Module end 'content' 1.09550.0015 1,444.828116.1875
Script end 1.0970  1,461.0156 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2927160.0002
Check MTime0.00130.1211160.0001
Mysql Total
Database connection0.00050.046410.0005
Mysqli_queries1.031794.0441730.0141
Looping result0.00070.0648710.0000
Template Total1.069397.520.5346
Template load0.00190.172020.0009
Template processing1.067497.297720.5337
Template load and register function0.00020.020710.0002
states
state_id_array0.00090.081910.0009
state_identifier_array0.00120.112620.0006
Override
Cache load0.00160.1460410.0000
Sytem overhead
Fetch class attribute can translate value0.00080.070840.0002
Fetch class attribute name0.00100.0920100.0001
XML
Image XML parsing0.00350.321040.0009
class_abstraction
Instantiating content class attribute0.00000.0022120.0000
General
dbfile0.00270.2450290.0001
String conversion0.00000.000540.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
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs