<![CDATA[ Getresources to php array or json string in a seperate file - My Forums]]> https://forums.modx.com/thread/?thread=97475 <![CDATA[Getresources to php array or json string in a seperate file]]> https://forums.modx.com/thread/97475/getresources-to-php-array-or-json-string-in-a-seperate-file#dis-post-527093 hitesh571985 Jun 17, 2015, 05:55 PM https://forums.modx.com/thread/97475/getresources-to-php-array-or-json-string-in-a-seperate-file#dis-post-527093 <![CDATA[Re: Getresources to php array or json string in a seperate file]]> https://forums.modx.com/thread/97475/getresources-to-php-array-or-json-string-in-a-seperate-file#dis-post-564148
The usual solution is to create your own snippet that gets the same array of resources with getCollection() (just like getResources does). That will give you a PHP array of Resource objects, which you can loop through and create the output you want.

You can convert each resource object into an array with $resource->toArray().

You can also use Tpl chunks with $modx->getChunk('ChunkName', $fields) where $fields is an array of placeholder names and their values. Sometimes it's as easy as $fields = $resource->toArray().]]>
BobRay Feb 19, 2019, 08:37 PM https://forums.modx.com/thread/97475/getresources-to-php-array-or-json-string-in-a-seperate-file#dis-post-564148
<![CDATA[Re: Getresources to php array or json string in a seperate file]]> https://forums.modx.com/thread/97475/getresources-to-php-array-or-json-string-in-a-seperate-file#dis-post-564141 willy21 Feb 19, 2019, 11:47 AM https://forums.modx.com/thread/97475/getresources-to-php-array-or-json-string-in-a-seperate-file#dis-post-564141