Forums / Developer / removing duplicate entries from 2 independent fetches

removing duplicate entries from 2 independent fetches

Author Message

steve walker

Wednesday 08 September 2004 8:28:12 am

Hi there,

I started to ask about this at the end of http://ez.no/community/forum/setup_design/advanced_search_development_homemade_fuzzy_logic but its really a seperate subject so wanted to start a fresh thread.

I have 2 independent fetches with the 2nd fetch likely to contain some identical data to the first fetch.

I want to perform some filtering on the second fetch so that it doesnt display any of the data that was already displayed via the first fetch.

Does anyone know of a way of doing this.

Many thanks, Steve.

http://www.oneworldmarket.co.uk

Ole Morten Halvorsen

Thursday 09 September 2004 2:09:10 am

Steve,

If the <b>unique</b> operator (http://ez.no/ez_publish/documentation/reference/template_operators/arrays/unique) cant help you I would recommend writing an operator for this purpose.

Ole M.

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

steve walker

Thursday 09 September 2004 2:24:53 am

Ole,

OK. In this case the potential issue is I have two independent fetches.

Is it possible to make an array out of the 2 fetches, so I have something on the lines of:

let fetch1 = fetch_some_data
let fetch2 = fectch_additional_data

let overall_results = array(fetch1,fetch2)|unique

RegardsSteve.

http://www.oneworldmarket.co.uk

Ole Morten Halvorsen

Thursday 09 September 2004 5:36:29 am

Steve,

Yes, you can use merge the two arrays with <b>merge</b>. Look here: http://ez.no/ez_publish/documentation/reference/template_operators/arrays/merge

I dont think the unique operator works on multidimensional arrays, so you might have to write your own operator to do this.

Ole M.

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

steve walker

Wednesday 15 September 2004 2:18:37 am

Ole,

Thanks for the information.

Regards, Steve.

http://www.oneworldmarket.co.uk

willy jansen

Wednesday 15 September 2004 7:33:38 am

Hi,

A slight different question. I have a fetch that returns duplicate entries (because there are articles that appear in more than 1 location).

Can I use "unique" to filter the duplicate entries out?

If yes: how?

Find below the code I'm using...
(It fetches the latest 6 additions from 100 nodes starting from node 2)

{let page_limit=8 
children=fetch(content, list, hash(limit, 6, 
parent_node_id, 2, 
depth, 100, sort_by,array(published,false()), 
class_filter_type, include, class_filter_array, array(article)))}

  <table class="2cols">
      <tr>
      {section name=Child loop=$children sequence=array(col1,col2)} 
        <td valign="top" class="{$Child:sequence}">
         {node_view_gui view=line content_node=$Child:item}
        </td>
        {delimiter modulo=2}
         </tr>
         <tr>
        {/delimiter}

      {/section}
    </tr>
  </table>

I'd highly appreciate a hint in the right direction.

steve walker

Wednesday 15 September 2004 8:02:24 am

Willy,

Have a look at:

http://www.ez.no/community/bug_reports/duplicates_when_fetching_trees_and_lists_with_objects_assigned_to_multiple_locations

You want to use the 'main_node_only, true()' within the fetch to only grab main node.

Regards, Steve.

http://www.oneworldmarket.co.uk

willy jansen

Wednesday 15 September 2004 9:36:21 am

Splendid.

This fetch does the trick now for me:

{let page_limit=8 
children=fetch(content, list, 
hash(limit, 6, parent_node_id, 2, 
depth, 100, main_node_only, true(), 
sort_by,array(published,false()), 
class_filter_type, include, class_filter_array, array(article)))}

John Kazakis

Tuesday 25 March 2008 9:56:34 am

Hello,

I just tried this and it doesn't seem to work :S

Here's my code:

{def $featured_folder = fetch( 'content', 'node', hash( 'node_path', concat($node.path_identification_string, '/featured') ) )
    
     $event_list = fetch( 'content', 'list', 
                          hash( 'parent_node_id',        $featured_folder.node_id,
                                'sort_by',               $featured_folder.sort_array,
                                'limit',                 4,
                                'limitation',            array(),
								main_node_only, true()
                              ) )
}

{*---------------------
    List the Events
---------------------*}
{foreach $event_list as $content sequence array( '0', '1' ) as $style}
    {if eq($style, 0) }
        {append-block variable=$left_components}           
            {node_view_gui view='box' box_type="listbox" content_node=$content display_register='1'}
        {/append-block}
    {else}
        {append-block variable=$right_components}            
            {node_view_gui view='box' box_type="listbox" content_node=$content display_register='1'}
        {/append-block}
    {/if}
{/foreach}

What am I missing?

Thanks.