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.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 30 2025 00:16:44
Script start
Timing: Jan 30 2025 00:16:44
Module start 'layout'
Timing: Jan 30 2025 00:16:44
Module start 'content'
Timing: Jan 30 2025 00:16:44
Module end 'content'
Timing: Jan 30 2025 00:16:45
Script end

Main resources:

Total runtime0.0171 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 588.1563151.2109
Module start 'layout' 0.00520.0032 739.367236.6563
Module start 'content' 0.00850.0067 776.023491.1406
Module end 'content' 0.01510.0019 867.164129.9766
Script end 0.0170  897.1406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002715.6962140.0002
Check MTime0.00137.4514140.0001
Mysql Total
Database connection0.00074.382310.0007
Mysqli_queries0.003319.234730.0011
Looping result0.00000.082410.0000
Template Total0.00137.810.0013
Template load0.00116.181510.0011
Template processing0.00031.593910.0003
Override
Cache load0.00074.393410.0007
General
dbfile0.001710.104280.0002
String conversion0.00000.040540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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