Skip to content

Instantly share code, notes, and snippets.

@wdebusschere
Created October 31, 2018 14:43
Show Gist options
  • Save wdebusschere/120cd631c7faff5d32d3bd86eab7be06 to your computer and use it in GitHub Desktop.
Save wdebusschere/120cd631c7faff5d32d3bd86eab7be06 to your computer and use it in GitHub Desktop.
Custom datasource with symql
<!--
Usecase example:
-->
public function allowEditorToParse()
{
return false;
}
public function execute(array &$param_pool = null)
{
$result = new XMLElement($this->dsParamROOTELEMENT);
// fetch categories
$query =new SymQLQuery('Categories');
$query
->select('system:id,title)
->from('categories')
->where('active', 'Yes')
->orderby('title', 'asc');
$resultsymqlquery = SymQL::run($query,SymQL::RETURN_ARRAY);
//var_dump($resultsymqlquery['entries'][0]['entry']);die;
foreach ($resultsymqlquery['entries'] as $entry => $value) {
$entry = new XMLElement('category');
$entry->setAttribute("id",$value['entry']['_id']);
$entry->setAttribute("title",$value['entry']['title']['value']);
$result->appendChild($entry);
}
return $result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment