eZ Community » Forums » Developer » eZContentObjectTreeNode::subTreeByNod...
expandshrink

eZContentObjectTreeNode::subTreeByNodeID and AttributeFilter problem

eZContentObjectTreeNode::subTreeByNodeID and AttributeFilter problem

Tuesday 31 August 2010 3:21:31 pm - 6 replies

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

Tuesday 31 August 2010 5:14:59 pm

Is it possible to create a OR statement inside AND ?

Something like (A OR B) AND C ?

Tuesday 31 August 2010 5:55:02 pm

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.

Tuesday 31 August 2010 6:04:15 pm

Thanks Yannick,

I'll try this tomorrow.

Tuesday 31 August 2010 10:00:56 pm

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

Thursday 02 September 2010 10: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 !

Thursday 02 September 2010 10: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.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from