Forums / General / attribute_filter and list_count giving me a headache!

attribute_filter and list_count giving me a headache!

Author Message

Andrew K

Wednesday 08 November 2006 9:05:06 am

I've got a class set up that has an date attribute identifier called featured_item_expiration. I have one node of this class in the folder node 77. When ever I try to run a list_count with an attribute filter on that date attribute it comes back as 0 even though the filter should pick up the one object here is my code:

{fetch(content, list_count,hash(parent_node_id, 77, attribute_filter,
	array(
		array('featured_item/featured_item_expiration', '>',currentdate())
	),ignore_visibility,true()
))}

If I take out the attribute_filter it will work and find 1 item. The value of featured_item_expiration is 2006-11-25.

What is wrong with my code? I'm going crazy trying to figure it out.

--Andrew

Claudia Kosny

Wednesday 08 November 2006 10:42:23 am

Hi Andrew

currentdate() returns a timestamp of the current date and time, e.g.1163014743. If you have only a date attribute the time is not considered which results in a timestamp of e.g. 1162965600 so the entry will match currentdate() only at midnight.

Best have a look at the sortkey property of the attribute featured_item_expiration, this should show what to compare against.

Greetings from Luxembourg

Claudia

Andrew K

Wednesday 08 November 2006 10:54:19 am

Right, but I'm doing a greater than filter, not an equals. And the sort_key_int is 1164434400. The sort_key_string is blank.

Claudia Kosny

Wednesday 08 November 2006 11:19:35 am

Hi Andrew

You are right, somehow I saw an equality sign there.Comes from stating at the screen all day long I suppose...

The code you posted should work fine, I have a similar setup and I get the correct number of nodes, so I am unfortunately not sure what is going wrong in your case.

Take a look at the created SQL query - maybe you can see what is going wrong there.
The condition for the attribute filter should look like this: ... AND ( a0.sort_key_int > '1163013261' ) AND ...

Good luck

Claudia

Andrew K

Wednesday 08 November 2006 3:32:02 pm

Ok. Here's the weird thing. I've got SQL Debugging turned on and there is no mention of sort_key_int in any of the queries.

Andrew K

Wednesday 08 November 2006 3:39:09 pm

I just noticed this message in the debug:

Attribute filter returned false

This message was right between a query that mentions the parent node and a query that mentioned the child node in question. What would that message indicate?

Andrew K

Wednesday 08 November 2006 3:44:13 pm

Ok. Just out of curiosity, I wiped out my cache directory and now it works just fine. Why would this have been cached?

Bruce Morrison

Wednesday 08 November 2006 8:16:54 pm

Hi Andrew

The "Attribute filter returned false" message indicates that the attribute filter is invalid.

Try moving the currentdate() into a variable and using that in the fetch:

{def $currentdate=currentdate()}
{fetch(content, list_count,
    hash(parent_node_id, 77, attribute_filter,
      array(array('featured_item/featured_item_expiration', '>',$currentdate)),
      ignore_visibility,true()
    )
)}

Cheers
Bruce

P.S. A google search like
site:pubsvn.ez.no "Attribute filter returned false"
Is great for pinpointing where is the code messages are generated from.

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

eZ debug

Timing: Jan 31 2025 03:28:23
Script start
Timing: Jan 31 2025 03:28:23
Module start 'content'
Timing: Jan 31 2025 03:28:23
Module end 'content'
Timing: Jan 31 2025 03:28:23
Script end

Main resources:

Total runtime0.2968 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.0100 588.0781370.2813
Module start 'content' 0.01000.0174 958.35941,009.6719
Module end 'content' 0.02740.2693 1,968.03133,898.2891
Script end 0.2968  5,866.3203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00471.5997200.0002
Check MTime0.00140.4586200.0001
Mysql Total
Database connection0.00110.382010.0011
Mysqli_queries0.186962.96181410.0013
Looping result0.00160.54931390.0000
Template Total0.268990.610.2689
Template load0.00110.366210.0011
Template processing0.267890.209310.2678
Override
Cache load0.00070.219310.0007
Sytem overhead
Fetch class attribute can translate value0.00200.668710.0020
XML
Image XML parsing0.00040.142910.0004
General
dbfile0.01063.5683200.0005
String conversion0.00000.001930.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.0002 secs