Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@web-ramos
Last active December 28, 2015 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save web-ramos/7515944 to your computer and use it in GitHub Desktop.
Save web-ramos/7515944 to your computer and use it in GitHub Desktop.
<?
require_once MODX_CORE_PATH.'components/shopmodx/processors/web/getdata.class.php';
class modWebGetdataProcessorsCat extends ShopmodxWebGetDataProcessor {
public function initialize(){
$this->setDefaultProperties(array(
'sort' => 'price.value',
'dir' => 'ASC',
'showhidden' => false,
'showunpublished' => false,
'getPage' => false,
'page' => !empty($_REQUEST['page']) ? (int)$_REQUEST['page'] : 0
));
if($page = $this->getProperty('page') AND $page > 1 AND $limit = $this->getProperty('limit', 0)){
$this->setProperty('start', ($page-1) * $limit);
}
return parent::initialize();
}
public function prepareQueryBeforeCount(xPDOQuery $c) {
$c = parent::prepareQueryBeforeCount($c);
$c->where(array(
'published' => 1,
'deleted' => 0,
'hidemenu' => 0,
));
return $c;
}
public function outputArray(array $array, $count = false) {
if($this->getProperty('getPage') AND $limit = $this->getProperty('limit')){
$this->modx->setPlaceholder('total', $count);
$this->modx->runSnippet('getPage@getPage', array(
'limit' => $limit,
));
}
return parent::outputArray($array, $count);
}
}
return modWebGetdataProcessorsCat;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment