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.