"Dynamic " select in template: HOW?

Author Message

PaoloMellerio kk

Monday 31 May 2004 8:35:27 am

Hi,
I've the need to have a SELECT object in one of my template whose lines are the result of a fetch of values contained in an attribute of one of my classes. My problem is that the lines of this SELECT must be UNIQUE, that is to say that the choice in the SELECT is restricted only at UNIQUE values coming from the fetch:

<select class="search" name="t219" id="Search">
<option selected value="">Choose</option>
{let myfolder=47 used_node=false()} {* 47 is the id of the folder containing the classes - ID=17 in which I must look...*}
{section loop=fetch(content,tree,hash(parent_node_id, $myfolder,class_filter_type, "include",class_filter_array, array(17)))}
<option>{$:item.data_map.myattributeclass.content}</option>
{/section}
{/let}
</select>

I don't understand how to make the Array Operator |UNIQUE to interact with my code to reach my need...

Any Idea?

THX in Advice

Paolo Mellerio (Clikka!com)

Paolo Mellerio
http://www.clikka.com

Trond Åge Kvalø

Tuesday 08 June 2004 7:38:50 am

Hello Paolo!

If I understand you correctly, the attribute may contain identical values, is that correct?

And you only want to show one of the identical values, right?

Then I would write your select like this:

<select class="search" name="t219" id="Search">
<option selected value="">Choose</option>
{let myfolder=47 used_node=false()} 
{let myAttributeValues=fetch(content,tree,hash(parent_node_id, $myfolder,class_filter_type, "include",class_filter_array, array(17)))}
{$myAttributeValues|unique} {*This is where you remove the duplicate values*}
{section loop=$myAttributeValues}
<option>{$:item.data_map.myattributeclass.content}</option>
{/section}
{/let}
</select>

I have not tested this, but try to see if it works.

best regards
trondåge

trondåge

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 19:29:42
Script start
Timing: Jan 18 2025 19:29:42
Module start 'layout'
Timing: Jan 18 2025 19:29:42
Module start 'content'
Timing: Jan 18 2025 19:29:42
Module end 'content'
Timing: Jan 18 2025 19:29:42
Script end

Main resources:

Total runtime0.0165 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.0059 589.3438152.6250
Module start 'layout' 0.00590.0029 741.968839.4609
Module start 'content' 0.00880.0056 781.429789.4609
Module end 'content' 0.01440.0020 870.890630.3047
Script end 0.0164  901.1953 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003420.8163140.0002
Check MTime0.00127.2260140.0001
Mysql Total
Database connection0.00106.329510.0010
Mysqli_queries0.002414.554930.0008
Looping result0.00000.091210.0000
Template Total0.00169.510.0016
Template load0.00095.454710.0009
Template processing0.00074.009210.0007
Override
Cache load0.00063.784710.0006
General
dbfile0.00031.797580.0000
String conversion0.00000.053640.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