Forums / General / attribute_filter: needs more explanation

attribute_filter: needs more explanation

Author Message

Thomas Brandl

Friday 19 September 2003 7:01:09 am

Hi guys,

Scenario:
I have a fetch(content, list,..) which correctly gets all the objects I want it to get, now I want to limit the result with attribute_filter.

First problem: I do not get it work with one argument only, like:
attribute_filter, array( 159, '=', 'aValue' )

it doesn't seem to be the correct syntax, any other is not intuitive for me and there's no example with only one argument, so I use the example I found:

attribute_filter,
array( 'or', array( 159, '=', 'aValue'' ), array( 156, '=', 'foobar' ))

attribute_id 156 is valid, but does o.c not contain foobar, it's an 'or' combination, so it shouldn't matter.

Now, take for granted, there is a attribute_id 159, it's a text line datatype, and be asured, there is an (published) object with a corresponding value 'aValue'!

I don't get it to fetch anything, no errors, no output.

I don't know where to start to look for the problem! Did I misunderstand anything?

Thanks very much for help!
t

Tom Couwberghs

Tuesday 23 September 2003 5:17:27 am

I had some problems with it too. But after some trial and error I found how it works.

If you want to filter only on one parameter just leave out the third parameter. It would look like this: array('or', array(156, '=', 'foobar'))

If you don't see anything appearing that could be lots of things. My advice -- first try a fetch without attribute_filter and if that's working -> start filtering.

Also check if you clear the cache entirely. There is a little mistake of the eZ crew in the clear cache script in 3.2 stable. Consult this thread: http://ez.no/developer/ez_publish_3/forum/install_configuration/cache_wont_clear_in_32

HTH

--
T

Thomas Brandl

Tuesday 23 September 2003 6:20:54 am

Hi Tom,

fetch without filtering is no problem, did not get any further.

Do you have a working example for me, maybe the problem lies somewhere else and I'm to blind to see!?

Thomas Brandl

Tuesday 23 September 2003 7:23:19 am

found this:
eZ is trying to find the value i'm looking for in ezcontentobject_attribute.sort_key_string:
... ( a0.sort_key_string = 'aValue' ) ...

This field is empty for all my records!

Besides, I don't understand it: If I'd decide to filter on some other attribute tomorrow, how should this value find its way into sort_key_String or sort_key_int?? Should't the field to search in depend solely on the datatype used for the attribute in question - data_text, data_int or data_float?

Thanks for enlightment
t

Tom Couwberghs

Wednesday 24 September 2003 12:51:14 am

The following code works for me:

{let folder_list=fetch( content, list, hash( parent_node_id, 2, sort_by, array( array( priority ) ),
attribute_filter, array('or', array(152, '=', '0')))) }

{section name=Folder loop=$folder_list}
<td class="topmenu">
<a href={concat( "/content/view/full/", $Folder:item.node_id, "/" )|ezurl}>{$Folder:item.name|wash}</a>
</td>
{/section}
{/let}

2 remarks:

About the no errors thing -> Is debug enabled on your site? If not switch it to enabled in site.ini

Are you using version 3.2 stable, in previous versions there was a bug that generated a wrong query?
HTH

--
Tom

eZ debug

Timing: Jan 30 2025 21:45:37
Script start
Timing: Jan 30 2025 21:45:37
Module start 'content'
Timing: Jan 30 2025 21:45:37
Module end 'content'
Timing: Jan 30 2025 21:45:37
Script end

Main resources:

Total runtime0.3321 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0406 587.9453370.2969
Module start 'content' 0.04060.0225 958.24221,005.5313
Module end 'content' 0.06310.2689 1,963.77343,895.5391
Script end 0.3321  5,859.3125 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00521.5612200.0003
Check MTime0.00150.4375200.0001
Mysql Total
Database connection0.00200.614810.0020
Mysqli_queries0.198959.89611410.0014
Looping result0.00160.48991390.0000
Template Total0.268480.810.2684
Template load0.00100.304110.0010
Template processing0.267480.497510.2674
Override
Cache load0.00060.181210.0006
Sytem overhead
Fetch class attribute can translate value0.00190.570810.0019
XML
Image XML parsing0.00030.085810.0003
General
dbfile0.02196.5943200.0011
String conversion0.00000.001430.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs