Forums / Setup & design / help with complex attribute_filter

help with complex attribute_filter

Author Message

Alessandro Cipriani

Wednesday 15 September 2004 3:09:17 am

hi all
i got to fetch some object of my class if:
attribute_322 = 0 AND (attribute_331 = current_user.login OR attribute_331 = 'all')

the attribute filter i use is:

attribute_filter, array(and,array(322,'=',0),array(or,array(331,'=',$current_user.contentobject.data_map.user_account.content.login),array(331,'=','all'))),

if i fetch the objects only by filtering the 331 attribute everything works, the problem arrives when i try to filter the 322 attribute too.

best regards
alessandro

Paul Borgermans

Wednesday 15 September 2004 4:37:52 am

Hi Alessandro

You cannot 'nest' and/or attribute filtering AFAIK. In similar instances, I use the patched ezobjectcontenttreenode.php class (see contribs) to allow for 'in' logic. This can be used in your situation.

hth

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Alessandro Cipriani

Wednesday 15 September 2004 6:00:42 am

thanks paul!
i downloaded the patched file, but i never used the 'in' clause.
please, can you give me an example on how to translate the 'and' (/'or') clause in the 'in' one?

best regards
alessandro

Paul Borgermans

Wednesday 15 September 2004 9:12:08 am

Hi Alessandro,

something like:

attribute_filter, array(and,array(322,'=',0),array(331,'in','(1,2,3)')))),

So the 'in' behaves like a nested 'or'

If you need text as possibilities, you will have to surround them with quotes and build your in variable outside the fetch in a {let} block. The array implode/concat operators are your friends there

simplified example:

{let myselection="('all','all-but-one')"

...   attribute_filter, array(and,array(322,'=',0),array(331,'in',$myselection)))),

{/let}

hth

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Alessandro Cipriani

Thursday 16 September 2004 1:01:12 am

hi paul
thanks for your replies
but i still am not able to get it work...
that's the code:

			{let memo=fetch( content, tree, hash( parent_node_id, 250,
									class_filter_type, "include",
									class_filter_array, array(42),
									depth, 10,
									attribute_filter, array(and,array(322,'=',0),array(331,'in',"('call','tutti')")),
									limit, 5,
									sort_by, array( published, false() )
									))}

and i don't retrieve any memo.
that's the sql output:

SELECT ezcontentobject.*,
ezcontentobject_tree.*,
ezcontentclass.name as class_name

, ezcontentobject_name.name as name, ezcontentobject_name.real_translation
FROM
ezcontentobject_tree,
ezcontentobject,ezcontentclass
, ezcontentobject_name

, ezcontentobject_attribute a1 , ezcontentobject_attribute a2

WHERE
path_string like '/1/2/250/%' and depth <= 12 and



a1.contentobject_id = ezcontentobject.id AND
a1.contentclassattribute_id = 322 AND
a1.version = ezcontentobject_name.content_version AND
a1.language_code = ezcontentobject_name.real_translation AND
a2.contentobject_id = ezcontentobject.id AND
a2.contentclassattribute_id = 331 AND
a2.version = ezcontentobject_name.content_version AND
a2.language_code = ezcontentobject_name.real_translation AND
( a1.sort_key_int = '0' AND a2.sort_key_string IN (\'call\',\'tutti\') ) AND
ezcontentclass.version=0 AND
node_id != 250 AND
ezcontentobject_tree.contentobject_id = ezcontentobject.id AND
ezcontentclass.id = ezcontentobject.contentclass_id AND

( ezcontentobject.contentclass_id = '42' ) AND
ezcontentobject_tree.contentobject_is_published = 1
and ezcontentobject_tree.contentobject_id = ezcontentobject_name.contentobject_id and
ezcontentobject_tree.contentobject_version = ezcontentobject_name.content_version and
ezcontentobject_name.content_translation = 'ita-IT'
AND ((ezcontentobject.section_id in (1, 10, 11, 5, 8)) or (ezcontentobject.contentclass_id in (16) AND ezcontentobject.section_id in (2)) or (ezcontentobject.section_id in (10, 6, 8)) or (ezcontentobject.contentclass_id in (44) AND ezcontentobject.section_id in (5)))

ORDER BY ezcontentobject.published DESC
LIMIT 0, 5

the error i retrieve when i paste the query in the mysql client is:
Error: You have mismatched `'`

any hint?
thanks a lot
alessandro

Paul Borgermans

Thursday 16 September 2004 1:28:22 am

Hi Alessandro,

Unfortunately you need to contruct the string for the 'in' filter outside the fetch to avoid the escapes on the quote characters.

{let myinstring=concat("('",'call',"','",'tutti',"')")
     memo=fetch( content, tree, hash( parent_node_id, 250,
		class_filter_type, "include",
		class_filter_array, array(42),
		depth, 10,
		attribute_filter, array(and,array(322,'=',0),array(331,'in',$myinstring)),
		limit, 5,
		sort_by, array( published, false() )
		))}
My inistring: {$myinstring}
{/let}

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Alessandro Cipriani

Friday 17 September 2004 6:33:15 am

paul
i pasted your code in my tpl but the error i get is the same:

SELECT ezcontentobject.*,
ezcontentobject_tree.*,
ezcontentclass.name as class_name

, ezcontentobject_name.name as name, ezcontentobject_name.real_translation
FROM
ezcontentobject_tree,
ezcontentobject,ezcontentclass
, ezcontentobject_name

, ezcontentobject_attribute a1 , ezcontentobject_attribute a2

WHERE
path_string like '/1/2/250/%' and depth <= 12 and



a1.contentobject_id = ezcontentobject.id AND
a1.contentclassattribute_id = 322 AND
a1.version = ezcontentobject_name.content_version AND
a1.language_code = ezcontentobject_name.real_translation AND
a2.contentobject_id = ezcontentobject.id AND
a2.contentclassattribute_id = 331 AND
a2.version = ezcontentobject_name.content_version AND
a2.language_code = ezcontentobject_name.real_translation AND
( a1.sort_key_int = '0' AND a2.sort_key_string IN (\'call\',\'tutti\') ) AND
ezcontentclass.version=0 AND
node_id != 250 AND
ezcontentobject_tree.contentobject_id = ezcontentobject.id AND
ezcontentclass.id = ezcontentobject.contentclass_id AND

( ezcontentobject.contentclass_id = '42' ) AND
ezcontentobject_tree.contentobject_is_published = 1
and ezcontentobject_tree.contentobject_id = ezcontentobject_name.contentobject_id and
ezcontentobject_tree.contentobject_version = ezcontentobject_name.content_version and
ezcontentobject_name.content_translation = 'ita-IT'
AND ((ezcontentobject.section_id in (1, 10, 11, 5, 8)) or (ezcontentobject.contentclass_id in (16) AND ezcontentobject.section_id in (2)) or (ezcontentobject.section_id in (10, 6, 8)) or (ezcontentobject.contentclass_id in (44) AND ezcontentobject.section_id in (5)))

ORDER BY ezcontentobject.published DESC
LIMIT 0, 5

Error: You have mismatched `'`

...
thanks for your patience..
best regards
alessandro

Alessandro Cipriani

Friday 17 September 2004 6:47:28 am

ooooops....
paul, i've seen where is the problem... i'm using the 3.4.0 version... is there nothing to do with the 3.4.0?
i can't upgrade right now....
thanx a lot
alessandro

Paul Borgermans

Friday 17 September 2004 7:07:06 am

Yes, must be a bug in 3.4.0 (or php settings?)

I tested it on 3.4.1 and 3.4.2 (from pubsvn) and it works here like intended.

I was thinking of making it easier, like the possibility to supply an array instead of a string, but too much time constraints now.

Don't you have other issues with 3.4.0 as well? Try hard to upgrade, lots of things have been fixed in the 3.4.2 branch on pubsvn

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

eZ debug

Timing: Jan 18 2025 04:58:56
Script start
Timing: Jan 18 2025 04:58:56
Module start 'content'
Timing: Jan 18 2025 04:58:57
Module end 'content'
Timing: Jan 18 2025 04:58:57
Script end

Main resources:

Total runtime0.9670 sec
Peak memory usage4,096.0000 KB
Database Queries212

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 587.7344180.8281
Module start 'content' 0.00500.8212 768.5625658.3984
Module end 'content' 0.82630.1405 1,426.9609349.0859
Script end 0.9668  1,776.0469 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.4305210.0002
Check MTime0.00150.1595210.0001
Mysql Total
Database connection0.00060.060510.0006
Mysqli_queries0.843587.22852120.0040
Looping result0.00200.20742100.0000
Template Total0.938397.020.4692
Template load0.00220.229820.0011
Template processing0.936196.807820.4680
Template load and register function0.00010.009910.0001
states
state_id_array0.00150.153010.0015
state_identifier_array0.00100.102220.0005
Override
Cache load0.00220.23011580.0000
Sytem overhead
Fetch class attribute can translate value0.00150.156830.0005
Fetch class attribute name0.00120.1285110.0001
XML
Image XML parsing0.00230.232930.0008
class_abstraction
Instantiating content class attribute0.00000.0042180.0000
General
dbfile0.00720.7462340.0002
String conversion0.00000.000730.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
9content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.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/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
20content/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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 58
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs