Last active
December 28, 2015 14:39
-
-
Save web-ramos/7515944 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
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