Forums / Developer / Urgent please: How to remove from fetch results duplicated entries?
Jorge estévez
Wednesday 23 February 2005 7:35:57 pm
Hello
Doing a fetch within several nodes could give as the result several values, some of them are duplicated because they are located in different parts of the node tree in the site.
I would like to remove duplicated values but the array is a multidimensional one (e.g. articles, so the operator used in Arrays "unique" does not remove duplicated entries.
Could someone point out how to do this?Can someone please give away a code that could perform this?
thanks
Diseño Web Cuba Web Design Cuba www.elfosdesign.com
Eirik Alfstad Johansen
Wednesday 23 February 2005 10:29:46 pm
Hi Joe,
If I've understood you correctly, the main_node_only parameter should do the trick.
{let children=fetch(content, list, hash(parent_node_id, 2, main_node_only, true()))} {/let}
Sincerely, Eirik Alfstad Johansen http://www.netmaking.no/
Friday 25 February 2005 2:26:45 pm
Sorry, but it does not work...
can someone else point out how to eliminate duplicated entries?
thanks anyway
Łukasz Serwatka
Saturday 26 February 2005 7:03:20 am
Rebuild multidimensional to one demensional array and then use unique function.
This should work if they have the same node_id (duplicated), If not then you must build array with their names for example.
{let node_array=array()} {section loop=fetch( content, tree, hash( parent_node_id, 2 ) ) } {set node_array=$node_array|append( $item.node_id ) } {/section} {section loop=$node_array|unique} Loops without duplicated values {/section} {/let}
Personal website -> http://serwatka.net Blog (about eZ Publish) -> http://serwatka.net/blog
Thursday 03 March 2005 3:50:58 pm
Lukasz
I did have to do some workarround but it worked all right..
Thanks a lot for the tip!It helped a lot!
liu spider
Sunday 06 March 2005 6:51:57 pm
I use the same approach as Eirik Johansen's, works just fine
http://liucougar.scim-im.org SCIM Input Method Platform http://scim.sf.net SJSD Online Editor http://sf.net/projects/sjsd