How to do multiple section in a template with one array with multiple arrays inside?

Author Message

Mauricio Monsalve

Saturday 31 July 2004 7:03:39 am

Hi.

I'm developing a new class that will give me some advices when users search for any thing. When I got the SearchText variable, I let EZ do it's work and I seek in a semantic database the posible contexts for SearchText. What I got finally is a multiple array, it has a gloss(definition of the word), an a set of synonym (Synset) of word related to this meaning, and I got as many glosses and synsets as the database has.

So, it can be something like this:

myArray = [ [gloss, synsets[] ],
[gloss, synsets[] ] ]

So I'm setting myArray as a template variable.

The idea is to do a section and a loop to print this results, let's put it in a code like way.

for (each element of myArray)
{
print element.gloss
for (each element.synset)
{
print element.synset.word
}
}

And the result should look like this:
Gloss1: word1, word2, ....
Gloss2: word1, word2, word3....
...

I search in the documentation, and it shows me how to do a section and a loop for a single array, and I'm trying to write some things but it didn't work.

Anyone can help me about this?

Bård Farstad

Tuesday 10 August 2004 2:46:33 am

You can use section to do this. Here is a small example.

{let double_array=array( hash( 'name', 'First Glossary', 'values', array( 'Word1', 'Word2', 'Word3' ) ),
                         hash( 'name', 'Second Glossary', 'values', array( 'Word1', 'Word2', 'Word3' ) ) )}
{section var=single_array loop=$double_array}
    {$single_array.name}:
    {section var=value loop=$single_array.values}
        {$value}
        {delimiter},{/delimiter}
    {/section}
    {delimiter}<br/>{/delimiter}
{/section}
{/let}

--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 31 2025 04:34:06
Script start
Timing: Jan 31 2025 04:34:06
Module start 'layout'
Timing: Jan 31 2025 04:34:06
Module start 'content'
Timing: Jan 31 2025 04:34:07
Module end 'content'
Timing: Jan 31 2025 04:34:07
Script end

Main resources:

Total runtime1.3143 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0045 588.6250151.2734
Module start 'layout' 0.00450.0026 739.898436.7578
Module start 'content' 0.00711.3065 776.6563924.6250
Module end 'content' 1.31360.0007 1,701.28137.7500
Script end 1.3143  1,709.0313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00280.2140160.0002
Check MTime0.00130.0952160.0001
Mysql Total
Database connection0.00050.041710.0005
Mysqli_queries1.263596.1342540.0234
Looping result0.00050.0411520.0000
Template Total1.279297.320.6396
Template load0.00160.122020.0008
Template processing1.277697.202920.6388
Template load and register function0.00150.111710.0015
states
state_id_array0.00180.133910.0018
state_identifier_array0.00140.104120.0007
Override
Cache load0.00130.1025290.0000
Sytem overhead
Fetch class attribute can translate value0.00070.050820.0003
Fetch class attribute name0.00240.184530.0008
XML
Image XML parsing0.00080.061320.0004
class_abstraction
Instantiating content class attribute0.00000.000630.0000
General
dbfile0.00090.0712170.0001
String conversion0.00000.000640.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
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.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/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs