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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 01:27:54
Script start
Timing: Jan 31 2025 01:27:54
Module start 'layout'
Timing: Jan 31 2025 01:27:54
Module start 'content'
Timing: Jan 31 2025 01:27:54
Module end 'content'
Timing: Jan 31 2025 01:27:54
Script end

Main resources:

Total runtime0.0265 sec
Peak memory usage6,144.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 588.2578151.2266
Module start 'layout' 0.00570.0035 739.4844220.7344
Module start 'content' 0.00910.0159 960.21881,001.9297
Module end 'content' 0.02510.0014 1,962.148433.9922
Script end 0.0265  1,996.1406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002910.8904140.0002
Check MTime0.00103.9555140.0001
Mysql Total
Database connection0.00082.856210.0008
Mysqli_queries0.00228.483130.0007
Looping result0.00000.045010.0000
Template Total0.00103.910.0010
Template load0.00082.867910.0008
Template processing0.00031.052510.0003
Override
Cache load0.00052.071810.0005
General
dbfile0.00248.935680.0003
String conversion0.00000.025240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs