Search

I've noticed that with simple filters using URL query parameters, like the one directly below, if the parameter is empty (or not exists) then there is no database where clause produced for this filter. This is very useful and I would like it to work the same for other filters.

field= type filter={$url-type}

I've got a datasource that I'm filtering on a date field to only select "past N months" of entries.

here's the filter

%2D {$url-months} months to today

as you can see it uses a url query string parameter. But in this case if {$url-months) does not exist the database query still uses the filter and returns no selected entries. Now I know that I can set a default value like this... {$url-months:9999)... to return all entries in this case but I'd rather the filter didn't apply and I have other problems that would have a nice solution if filters like these wouldn't apply if the parameters did not exist. Is there a way to do this that I'm not aware of?

I guess the easiest way would be to customize your datasource and unset the filter in the $dsParamFILTERS array at the beginning of grab() function in your datasource. Don't forget to return false in allowEditorToParse() then to prevent overwriting your changes from the DS editor.

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