eZContentObjectTreeNode::subTreeByNodeID and AttributeFilter problem

Author Message

Damien MARTIN

Tuesday 31 August 2010 6:21:31 am

Hi there,

I would like to know why the following pieces of code don't works :

1. I create an array with all my search filters

$criteres = array("and");
if($siren != "")
    $criteres[] = array('etablissement/n_siren', 'like', "*$siren*");

I do this piece of code for a lot of criters, adding a sub array to the criteres array.

2. I launch my fetch :

$entreprises = eZContentObjectTreeNode::subTreeByNodeID(
    array(
        'ClassFilterType' => 'include',
        'ClassFilterArray' => array('etablissement'),
        'AttributeFilter' => $criteres
    ),
    2283
);

But there is nothing in $entreprises...

There is things I don't understand : why the same code :

if($tel != "")
    $criteres[] = array('etablissement/tel', 'like', "*$tel*");

and

if($nom != ""){
    $criteres[] = array('etablissement/nom', 'like', "*$nom*");
    $criteres[] = array('etablissement/nom_enseigne', 'like', "*$nom*");
}

don't do the same thing ?

>> For the phone number ($tel), it works perfectly even if the number is not complete.
>> But for the name ($nom), there is nothing (even with the complete name or part of the name).

Could someone explain me what is wrong ? Or why does it works like this ?

Thanks

Damien MARTIN

Tuesday 31 August 2010 8:14:59 am

Is it possible to create a OR statement inside AND ?

Something like (A OR B) AND C ?

Yannick Komotir

Tuesday 31 August 2010 8:55:02 am

Hi,

I don't think it's possible with regular filtering (like with ezfind), look at nxc extended filter or create your own extend filter.

<|- Software Engineer @ eZ Publish developpers -|>
@ http://twitter.com/yannixk

Damien MARTIN

Tuesday 31 August 2010 9:04:15 am

Thanks Yannick,

I'll try this tomorrow.

Gaetano Giunta

Tuesday 31 August 2010 1:00:56 pm

One thing: the wildcard character for 'like' is '%', not '*'

Principal Consultant International Business
Member of the Community Project Board

Damien MARTIN

Thursday 02 September 2010 1:45:25 am

"

One thing: the wildcard character for 'like' is '%', not '*'

"

I just tried Gaetano : the wildcard '%' doesn't work at all. It is really '*' like it is said in the template operators documentation :

http://ez.no/doc/ez_publish/technical_manual/4_x/reference/modules/content/fetch_functions/list

"

I don't think it's possible with regular filtering (like with ezfind), look at nxc extended filter or create your own extend filter.

"

I'm sorry Yannick I doesn't have had time to try this, I merged my datas in a hidden field who is updated automaticaly instead.

Thank you eveybody !

Damien MARTIN

Thursday 02 September 2010 1:53:08 am

In fact, the probleme about the name field was just an error in my code :

if($nom != ""){
    $criteres[] = array('etablissement/nom', 'like', "*$nom*");
    $criteres[] = array('etablissement/nom_enseigne', 'like', "*$nom*");
}

But the two fields are not always filled and not always with the same datas... (shame on me).

So it is fixed.

Thank you again guys.

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 01:56:03
Script start
Timing: Jan 18 2025 01:56:03
Module start 'layout'
Timing: Jan 18 2025 01:56:03
Module start 'content'
Timing: Jan 18 2025 01:56:04
Module end 'content'
Timing: Jan 18 2025 01:56:04
Script end

Main resources:

Total runtime0.7471 sec
Peak memory usage4,096.0000 KB
Database Queries73

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 588.2031152.6563
Module start 'layout' 0.00630.0026 740.859439.4922
Module start 'content' 0.00890.7367 780.3516645.0000
Module end 'content' 0.74560.0014 1,425.351620.0938
Script end 0.7470  1,445.4453 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4777160.0002
Check MTime0.00150.2024160.0001
Mysql Total
Database connection0.00080.106810.0008
Mysqli_queries0.659188.2287730.0090
Looping result0.00090.1182710.0000
Template Total0.707394.720.3537
Template load0.00220.296620.0011
Template processing0.705194.381920.3526
Template load and register function0.00020.021710.0002
states
state_id_array0.00230.306710.0023
state_identifier_array0.00120.163820.0006
Override
Cache load0.00200.2674570.0000
Sytem overhead
Fetch class attribute can translate value0.00060.084530.0002
Fetch class attribute name0.00120.1626100.0001
XML
Image XML parsing0.00450.595830.0015
class_abstraction
Instantiating content class attribute0.00000.0034140.0000
General
dbfile0.00550.7408280.0002
String conversion0.00000.001240.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
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
18content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/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
3content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
2content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 45
 Number of unique templates used: 9

Time used to render debug report: 0.0001 secs