Как создавать собственные галереи на основе Gallery, я писал здесь.
А по поводу возвращаемого JSON-а: изначально modProcessor::outputArray() возвращает JSON-строку.
public function outputArray(array $array,$count = false) { if ($count === false) { $count = count($array); } return '{"total":"'.$count.'","results":'.$this->modx->toJSON($array).'}'; }
Но так как мы часто пишем метод process сами, и возвращаем в нем $this->success() или $this->failure(), то $this->outputArray() мы и не замечаем. А вот modObjectGetListProcessor в process() именно его и возвращает.
public function process() { $beforeQuery = $this->beforeQuery(); if ($beforeQuery !== true) { return $this->failure($beforeQuery); } $data = $this->getData(); $list = $this->iterate($data); return $this->outputArray($list,$data['total']); }
Вот поэтому ты на выходе и получаешь JSON. Перегрузи outputArray и все. Можешь в нем $this->success($msg, $array) вернуть, а можешь сразу массив вернуть, как у меня в getdata-процессорах.
public function outputArray(array $array, $count = false){ return array( 'success' => true, 'message' => $this->getMessage(), 'count' => count($array), 'total' => $count, 'object' => $array, ); }