Karsten Jennissen
|
Monday 29 January 2007 4:23:30 am
Hi all, I want to create a search function that works as follows:
* look into a node tree
* collect all avaible selection texts from a specific selection attribute
* display them * texts are clickable and click shows all full objects that have that specific text in the selection attibute
E.g.
Contact address class, country is a selection attribute, I want to search the node tree of available contacts and show only those countries in a list that are in the contact database. How can I set up a fetch statement for this? I also want to do this for textline attributes. E.g. the city in the address card is a textline. I want to be able to show all cities in the database. Any tips on how to do this with a fetch function?
Thanks, Karsten
|
Karsten Jennissen
|
Monday 29 January 2007 11:59:42 pm
I found a solution, for those that are interested. Part 1: Display all the values of the attribute "sitz", if a value occurs more than once, show it only once. Count using attribute_filter. Generate a link per value with a view parameter "sitz" and the value as the parameter
{* Die Sitze durchlaufen. Wenn der Firmensitz noch nicht im Array enthalten ist, append. *}
{def $aktuellersitz=''}
{foreach $gruender as $aktuellergruender}
{set $aktuellersitz=$aktuellergruender.object.data_map.sitz.content}
{if $sitze|contains($aktuellersitz)|not()}
{set $sitze=$sitze|append($aktuellersitz)}
{/if}
{/foreach}
{* Ergebnisliste der Sitze durchlaufen, Anzahl anzeigen und Link zu Anzeigemaske generieren *}
{foreach $sitze as $sitzanzeige}
{def $sitzanzahl=fetch( content, list_count, hash( parent_node_id, 69, attribute_filter, array( array( 'gruender/sitz', '=', $sitzanzeige) ) ) ) }
{def $mainurlalias=concat($node.url_alias, "/(sitz)/", $sitzanzeige)}
<a href={$mainurlalias|ezurl()}>{$sitzanzeige}</a> ({$sitzanzahl})<br />
{/foreach}
Part 2: Display using the view_parameter and attribute_filter:
{if $view_parameters.sitz}
<h2>Firmensitz in {$view_parameters.sitz}</h2>
{def $filterergebnis=fetch( content, list, hash( parent_node_id, 69, attribute_filter, array( array( 'gruender/sitz', '=', $view_parameters.sitz) ) ) ) }
{foreach $filterergebnis as $gruender}
{node_view_gui view=line content_node=$gruender}
{/foreach}
{else}
...
|