Search

I am using Nick's excellent SymQL extension, which is really cool the way it allows me to create custom datasources without really understanding all of the MySQL LEFT JOIN's and whatnot. I feel powerful. =)

Most of my code is in the grab function

public function grab(&$param_pool){
    // MY CODE HERE
}

Is it possible to add a custom page parameter from a value within this function? How might I go about doing that? Thanks for your help!

When datsources are executed, everything else has already been resolved, namely parameters and events. So you can use it, of course, by adding some code early in the grab() function. You can even filter the DS based on some parameter value (e.g. foo):

// Custom filter
$this->dsParamFILTERS['6'] = '$param_pool['foo']';
//

(Please note the hardcoded field ID.)

What you basically do here is add another key/value pair to the dsParamFILTERS array before the filters get resolved.

[EDIT]: And of course you can also use the params in a SymQLQuery.

Is it possible to add a custom page parameter from a value within this function

Not entirely sure what you mean. Are you on a page /mypage/:param and you need to change the value of param even after the page has run?

You can return param pool values from a data source by modifying the $param_pool variable that is passed to the grab function. The convention is to use the naming convention ds-{your-ds-element-name}, for example:

$param_pool['ds-' . $this->dsParamROOTELEMENT] = 'foo';

This should create an output param in your page XML, and a param that other data sources can filter on.

Thanks Nick and Michael, I was able to get a param added using Nick's code. Woo!

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