Search

In a datasource you can filter so that an empty result will be returned when a parameter does not have a value. I would like to do the opposite. Can this be done any other way then always include the DS and test against a url param being empty in the xslt?

I don't think you can do this natively. Couldn't you add a filter on, say, System ID in your data source and use this parameter as a value. If the parameter value is a string ("blahblah" for example), when present, the DS will try and filter the entry IDs by this string, and will return no matches.

Alternatively you could modify the data source PHP file itself. It will be found in /workspace/data-sources. Start by changing the return value of the allowEditorToParse() function to false to prevent you editing this DS in the Data Source editor in the future, thereby overwriting your customisation.

Then add the following to the top of the grab() function:

if ($this->_env['param']['parameter-name'] != '') {
    $this->_force_empty_result = true;
}

This says that if the parameter named parameter-name is not empty, force the data source to return empty XML even if it finds matching entries.

The parameter name can be any parameter you find in the Params list when debugging your page. To see the full list in PHP array form, try this in the grab() function and refresh the page:

var_dump($this->_env);
die;

Then view the page source in your browser to see a nested list of all possible parameters.

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