Конвертировать в JSON

Есть ли возможность преобразовать результат от сннипетов pdoResources/getResources в JSON который приходит без указания Tpl
Array
(
    [id] => 1116
    [type] => document
    [contentType] => text/html
    [pagetitle] => testtitle
    [longtitle] => test
    [alias] => test
    [link_attributes] => 
    [published] => 1
    [pub_date] => 0
    [unpub_date] => 0
    [parent] => 94
    [isfolder] => 0
    [introtext] => адаптация манги
    [richtext] => 1
    [template] => 2
    [menuindex] => 41
    [searchable] => 1
    [cacheable] => 1
   
)
что бы на выходе было
{"id":1116,"type":"document","pagetitle":"testtitle"} // и тд

без вспомогательных чанков?
Саша Пекшев
18 октября 2014, 17:14
modx.pro
3 544
0

Комментарии: 6

Василий Наумкин
18 октября 2014, 23:03
2
+3
Нужен сниппет-обёртка:
<?php
$pdo = $modx->getService('pdoFetch');
$scriptProperties['return'] = 'data';
$pdo->setConfig($scriptProperties);
$result = $pdo->run();

return $modx->toJSON($result);

Вызывать точно также, как pdoResources:
[[!pdoResourcesWrapper?
	&parents=`0`
	&includeTVs=`mytv`
]]
На выходе получишь JSON.
Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
6