Forums / Setup & design / "Dynamic " select in template: HOW?

"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