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
|