Forums / Extensions / eZ Find / ezFind empty field

ezFind empty field

Author Message

Ivan Švogor

Tuesday 22 March 2011 8:22:08 am

Hi,

I'm filtering my articles in the way you don't see ones that are expired, It looks similar to this:

[1]   {set $filter = $filter|append('article/unpublish_date:[NOW/DAY-100DAY TO NOW]')}

This is supposed to print out all the articles that are expired (not older than 100 day). Now, It works ok. When I want to printout only those that are not expired I use something like this:

[2]  {set $filter = $filter|append('article/unpublish_date:[NOWTO NOW/DAY+100DAY]

Also, works ok. The problem: I have a lot of articles with unset attribute unpublish_date. So the filter 2 prints only the ones that have unpublish_date set. (therefore this question essentialy means, can I do something like this?:)

{set $filter = $filter|append('article/unpublish_date:[" "]')} -> not working :)

Is there a way to print out and those ones that have this field empty? If I need to set unpublish_date to all the early articles (when default value was not set) I will shoot myself :)

tnx

Ivan Švogor

Wednesday 23 March 2011 1:47:06 am

Yeah... I've figured it out..

Someone on this forum sayd that [ * TO NOW] or any combination of this will work for dates. For some reason it does not work for me. So where the * comes, I just use some timespan that will not happen. I doubt that articles will be older than 100 years, or unpublish date will be later than 100 years.

So I'm using this:

[NOW TO NOW/DAY+100DAY]

If attribute unpublish_date is not set, some suggest you set the filter like so:

'-article/unpublish_date:[* TO *]'

But it doesn't work for me :)

So the solution to my question is:

For all articles that are expired:

'article/unpublish_date:[NOW/DAY-100YEAR TO NOW]'

And for all that are not expired, and also don't have the unpublis_date attribute set:

'filter', array('or', 'article/unpublish_date:1970-01-01T01\:00\:00Z', 'article/unpublish_date:[NOW TO NOW/DAY+100YEAR]')

And that's it, I hope someone else will find this useful.