class SuperboxselectResourcesGetListProcessor extends modObjectGetListProcessor {
public $classKey = 'extUser';
public $languageTopics = array('superboxselect:default');
public $defaultSortField = 'username';
public $defaultSortDirection = 'DESC';
public $objectType = 'resellers.extuser';
public $displayField;
public function prepareQueryBeforeCount(xPDOQuery $c) {
// Get Properties
$parents = explode(',', $this->getProperty('parents', '0'));
$classKey = $this->getProperty('className', 'extUser');
//$modx->log(3,'class key: ' . $classKey);
$displayField = $this->getProperty('displayField', 'username');
$this->displayField = $displayField;
$resource_id = intval($this->getProperty('resource_id'));
$context_key = $this->getProperty('context_key', false);
$depth = $this->getProperty('depth', 10);
$limitRelatedContext = $this->getProperty('limitRelatedContext', false);
// Get the context of the current edited resource
if (!$context_key) {
$resource = $this->modx->getObject('modResource', $resource_id);
$context_key = $resource->get('context_key');
}
$c->select(array('id', $displayField));
$c->where(array(
'deleted' => false,
'published' => true
));
return $c;
}
public function prepareQueryAfterCount(xPDOQuery $c) {
$displayField = $this->getProperty('displayField', 'username');
$c->sortby($displayField, 'ASC');
return $c;
}
}
return 'SuperboxselectResourcesGetListProcessor';
This question has been answered by dmeganoski. See the first response.
I am trying to modify the superbox select plugin to query a list of my extended user class (extUser) which simply adds a relation to a custom table to the user class.
If I switch the 'classname' and 'displayfield' to the custom object I relate the users to, I can get a list of my custom objects just fine.
If I try to switch the classname to 'extUser' (using username as a display field) I get no results.
Here is a simple version of the getlist processor class.
Can anyone tell me what I am missing?
class SuperboxselectResourcesGetListProcessor extends modObjectGetListProcessor { public $classKey = 'extUser'; public $languageTopics = array('superboxselect:default'); public $defaultSortField = 'username'; public $defaultSortDirection = 'DESC'; public $objectType = 'resellers.extuser'; public $displayField; public function prepareQueryBeforeCount(xPDOQuery $c) { // Get Properties $parents = explode(',', $this->getProperty('parents', '0')); $classKey = $this->getProperty('className', 'extUser'); //$modx->log(3,'class key: ' . $classKey); $displayField = $this->getProperty('displayField', 'username'); $this->displayField = $displayField; $resource_id = intval($this->getProperty('resource_id')); $context_key = $this->getProperty('context_key', false); $depth = $this->getProperty('depth', 10); $limitRelatedContext = $this->getProperty('limitRelatedContext', false); // Get the context of the current edited resource if (!$context_key) { $resource = $this->modx->getObject('modResource', $resource_id); $context_key = $resource->get('context_key'); } $c->select(array('id', $displayField)); $c->where(array( 'deleted' => false, 'published' => true )); return $c; } public function prepareQueryAfterCount(xPDOQuery $c) { $displayField = $this->getProperty('displayField', 'username'); $c->sortby($displayField, 'ASC'); return $c; } } return 'SuperboxselectResourcesGetListProcessor';