Search

I'm trying to filter a datasource on a number field, but I'm running into trouble with the syntax. The field is optional, and I want any results where it's not set to be returned anyway. The following works if the value is set:

`greater than {$url-number}`

However, it doesn't return the empty value entries. Is there a syntax for 'or null', something like greater than {$url-number}, ''

Any Suggestions?

Thanks, Fish

EDIT: Sorry - I should have done more searching before posting. I see NULL filtering has been discussed before.

Further to the above, since it seems it doesn't have this functionality, can anyone suggest how the SQL query in the number field could be appended to include the null values?

For example, the X to Y filter uses:

$joins .= " LEFT JOIN `sym_entries_data_$field_id` AS `t$field_id` ON (`e`.`id` = `t$field_id`.entry_id) "; $where .= " AND `t$field_id`.`value` BETWEEN {$match[1]} AND {$match[2]} ";

I tried appending "OR t$field_id.value IS NULL" to $where, but that produced odd results and exposed my poor knowledge of SQL.

I've already updated it to handle when the url parameter isn't set, but this is I think beyond me, so any ideas would be much appreciated.

Thanks, Fish

Excuse the talking to myself here, but in case anyone else happens upon a similar issue, bracketing the condition was the solution. E.g.: AND ( t$field_id.value < $match[3] OR t$field_id.entry_id IS NULL)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details