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.

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 18 2025 19:24:28
Script start
Timing: Jan 18 2025 19:24:28
Module start 'layout'
Timing: Jan 18 2025 19:24:28
Module start 'content'
Timing: Jan 18 2025 19:24:29
Module end 'content'
Timing: Jan 18 2025 19:24:29
Script end

Main resources:

Total runtime0.9270 sec
Peak memory usage4,096.0000 KB
Database Queries79

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0082 588.1406152.6406
Module start 'layout' 0.00820.0039 740.781339.4766
Module start 'content' 0.01210.9132 780.2578641.6563
Module end 'content' 0.92520.0017 1,421.914120.1250
Script end 0.9269  1,442.0391 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.3636160.0002
Check MTime0.00140.1551160.0001
Mysql Total
Database connection0.00140.156210.0014
Mysqli_queries0.854792.1974790.0108
Looping result0.00110.1146770.0000
Template Total0.889395.920.4447
Template load0.00190.200020.0009
Template processing0.887595.735420.4437
Template load and register function0.00030.037510.0003
states
state_id_array0.00080.085210.0008
state_identifier_array0.00220.233220.0011
Override
Cache load0.00160.1721540.0000
Sytem overhead
Fetch class attribute can translate value0.00060.064740.0001
Fetch class attribute name0.00130.136190.0001
XML
Image XML parsing0.00070.080140.0002
class_abstraction
Instantiating content class attribute0.00000.001690.0000
General
dbfile0.00070.0785100.0001
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
9content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 29
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs