Romain Bremaud
|
Tuesday 05 April 2011 12:46:03 am
Hi. I have the same problem, I use the following code for resolve it (this solution is for a Dropdown list) . In a first time I fecth the class
{def $myclass = fetch( 'content', 'class', hash( 'class_id', 42 ) )} I copied and adapted the code present in edit/ezobjectrelationlist.tpl
{let class_content=$myclass.data_map.my_attribute.content}
{let parent_node=cond( and( is_set( $class_content.default_placement.node_id ),
$class_content.default_placement.node_id|eq( 0 )|not ),
$class_content.default_placement.node_id, 1 )
nodesList=cond( and( is_set( $class_content.class_constraint_list ), $class_content.class_constraint_list|count|ne( 0 ) ),
fetch( content, tree,
hash( parent_node_id, $parent_node,
class_filter_type,'include',
class_filter_array, $class_content.class_constraint_list,
sort_by, array( 'name',true() ),
main_node_only, true() ) ),
fetch( content, list,
hash( parent_node_id, $parent_node,
sort_by, array( 'name', true() )
) ))} And finally I write the dropdow list :
<div class="buttonblock">
<input name="single_select_{$attribute.id}" value="1" />
<select name="powercontent_my_attribute_ContentObjectAttribute_data_object_relation_list_pcattributeid[]">
{if $attribute.contentclass_attribute.is_required|not}
<option value="no_relation" {if eq( $attribute.content.relation_list|count, 0 )} selected="selected"{/if}>{'No relation'|i18n( 'design/standard/content/datatype' )}</option>
{/if}
{section var=node loop=$nodesList}
<option value="{$node.contentobject_id}"
{if ne( count( $attribute.content.relation_list ), 0)}
{foreach $attribute.content.relation_list as $item}
{if eq( $item.contentobject_id, $node.contentobject_id )}
selected="selected"
{break}
{/if}
{/foreach}
{/if}
>
{$node.name|wash}</option>
{/section}
</select>
</div> It works for me. Romain
Romain Bremaud
Les clefs du net
|