Forums / Developer / eZContentObjectTreeNode::subTreeByNodeID and AttributeFilter problem

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.

eZ debug

Timing: Jan 17 2025 22:46:39
Script start
Timing: Jan 17 2025 22:46:39
Module start 'content'
Timing: Jan 17 2025 22:46:40
Module end 'content'
Timing: Jan 17 2025 22:46:40
Script end

Main resources:

Total runtime0.8205 sec
Peak memory usage4,096.0000 KB
Database Queries210

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 589.1016180.7969
Module start 'content' 0.00560.7138 769.8984648.1875
Module end 'content' 0.71940.1009 1,418.0859341.0234
Script end 0.8204  1,759.1094 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00430.5206210.0002
Check MTime0.00160.1952210.0001
Mysql Total
Database connection0.00080.098610.0008
Mysqli_queries0.726888.58282100.0035
Looping result0.00210.25122080.0000
Template Total0.789796.220.3948
Template load0.00260.320820.0013
Template processing0.787095.925620.3935
Template load and register function0.00010.010310.0001
states
state_id_array0.00100.127910.0010
state_identifier_array0.00120.141320.0006
Override
Cache load0.00250.3018570.0000
Sytem overhead
Fetch class attribute can translate value0.00160.194140.0004
Fetch class attribute name0.00090.1102100.0001
XML
Image XML parsing0.00210.258540.0005
class_abstraction
Instantiating content class attribute0.00000.0049140.0000
General
dbfile0.00440.5351390.0001
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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