Forums / General / How to remove from search result duplicated entries?

How to remove from search result duplicated entries?

Author Message

Łukasz Serwatka

Tuesday 07 December 2004 1:25:21 am

Hi,

I`m looking for content

{let SearchType=fetch( content, search, 
               hash( text, $view_parameters.lang,
               class_attribute_id, 230 ) )}

{section loop=$SearchType['SearchResult']}
         {attribute_view_gui 
attribute=$:item.object.data_map.attr_name} <br />
    {/section}

The result is:

AAA
BBB
AAA
CCC
AAA
BBB

How to remove duplicated entries? Something like DISTINCT in SQL language.

AAA
BBB
CCC

I try with unique() funtion, but the result is strange. It displays only first entry.

AAA

{section loop=$SearchType['SearchResult']|unique}
    .
    .
    .
{/section}

I`ve idea to create one dimension array with strings form search results and use unique() function on it.

Probably it will not work at all

{ array( }
    { section loop=$SearchType['SearchResult'] }
        '{ attribute_view_gui attribute=$:item.object.data_map.attr_name }'
        
        {delimiter}
        ,
        {/delimiter}

    {/section}
{ ) }

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Silke Fox

Tuesday 07 December 2004 3:16:36 am

Hi Luke,

what do you want to do? Show all possible values of the selection attribute?

If yes, you can do something like this:

{let result=fetch('content','class_attribute',hash('attribute_id',230))}

If no, please tell us more...

Łukasz Serwatka

Tuesday 07 December 2004 3:28:38 am

Hi,

Show all possible values of the selection attribute?

I need to view "type" (attribute value) only for creted objects where lang=value

The class have attributes

1. lang - string
2. type - ezselection (no multiple)

So i looking for objects where attribute "lang" have value "english" and next i need to view "type" of this objects

1. object Lang=english Type=A
2. object Lang=english Type=A
3. object Lang=english Type=B
4. object Lang=english Type=A

Result of this for lang=english

{let SearchType=fetch( content, search, 
               hash( text, $view_parameters.lang,
               class_attribute_id, 230 ) )}

{section loop=$SearchType['SearchResult']}
         {attribute_view_gui 
attribute=$:item.object.data_map.attr_name} <br />
    {/section}

is

A
A
B
A

I need to view unique values

A
B

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Silke Fox

Tuesday 07 December 2004 5:32:45 am

Okay, I think you're on the right way. Use "append" to build an array with the attribute values and then "unique".

Try something like this (not sure if it will work exactly like this):

{let attrArray=array()}
{section var=Attributes loop=$SearchType['SearchResult']}
{set attrArray=$attrArray|append($Attributes.item.object.data_map.attr_name.content)}
{/section}
{$attrArray|count}
{set attrArray=$attrArray|unique}
{$attrArray|count}
{/let}

Good luck.
silke