$corePath = $modx->getOption('psyab.core_path',null,$modx->getOption('core_path').'components/psyab/');
require_once $corePath.'model/psyAb/psyab.class.php';
$modx->addPackage('psyAb',$corePath.'model/');
$modx->psyab = new psyAb($modx);
$modx->lexicon->load('psyab:default');
//echo $modx->lexicon('desc');
/* handle request */
$path = $modx->getOption('processorsPath',$modx->psyab->config,$corePath.'processors/');
$modx->request->handleRequest(array(
'processors_path' => $path,
'location' => '',
));
$xpdo = new xPDO('mysql:host=localhost;dbname=dbname', 'login', 'pass', 'prefix_');
$modx->addPackage('psyAb',$corePath.'model/');$modx->addPackage('psyAb',$corePath.'model/', 'prefix_');
public function connect () {
return new xPDO('mysql:host=localhost;dbname=dbname', 'login', 'pass', 'prefix_');
}
$corePath = $modx->getOption('psyab.core_path',null,$modx->getOption('core_path').'components/psyab/');
require_once $corePath.'model/psyAb/psyab.class.php';
$modx->addPackage('psyAb',$corePath.'model/');
$modx->psyab = new psyAb($modx);
$modx->psyab->data = $modx->psyab->connect(); // just an example
$modx->lexicon->load('psyab:default');
//echo $modx->lexicon('desc');
/* handle request */
$path = $modx->getOption('processorsPath',$modx->psyab->config,$corePath.'processors/');
$modx->request->handleRequest(array(
'processors_path' => $path,
'location' => '',
));
class JournalGetListProcessor extends modObjectGetListProcessor {
public $classKey = 'Journal';
public $languageTopics = array('psyab:default');
public $defaultSortField = 'title';
public $defaultSortDirection = 'ASC';
public $objectType = 'psyab.journal';
}
Where should I call this custom $modx->psyab->connect() to get it working?
<?php
class JournalGetListProcessor extends modObjectGetListProcessor {
public $classKey = 'Journal';
public $languageTopics = array('psyab:default');
public $defaultSortField = 'title';
public $defaultSortDirection = 'ASC';
public $objectType = 'psyab.journal';
/**
* ///////////// You are overriding this method! ///////////////
*
* Get the data of the query
* @return array
*/
public function getData() {
$data = array();
$limit = intval($this->getProperty('limit'));
$start = intval($this->getProperty('start'));
$c = $this->modx->psyab->data->newQuery($this->classKey);
$c = $this->prepareQueryBeforeCount($c);
$data['total'] = $this->modx->psyab->data->getCount($this->classKey, $c);
$c = $this->prepareQueryAfterCount($c);
$sortClassKey = $this->getSortClassKey();
$sortKey = $this->modx->psyab->data->getSelectColumns($sortClassKey, $this->getProperty('sortAlias', $sortClassKey), '', array($this->getProperty('sort')));
if (empty($sortKey))
$sortKey = $this->getProperty('sort');
$c->sortby($sortKey, $this->getProperty('dir'));
if ($limit > 0) {
$c->limit($limit, $start);
}
$data['results'] = $this->modx->psyab->data->getCollection($this->classKey, $c);
return $data;
}
}
return 'JournalGetListProcessor';