-
- 21 Posts
Can we get getresources output to a php file as array or json string?
-
- 24,544 Posts
I hate to disagree with Susan, but you won't get an array or a JSON string out of that unless you parse the results yourself (doable, but not trivial). getResources returns one big string with the full results. You might be able to modify your Tpl chunk to wrap the result with a snippet that would convert things for you, but I think it would be fairly slow and would use a lot of memory.
If you don't need all the bells and whistles of getResources, you can use a custom snippet.
If you want to post your getResources call and describe the format you want to save, we might be able to come up with some code for you.
Well, I'll be... I could have sworn that getResources had a toJSON property!
-
- 5,888 Posts
migxLoopCollection has a &toJsonPlaceholder - property
[[!migxLoopCollection?
&classname=`modResource`
&where=`{"parent:IN":[1,2,3],"deleted":"0","published":"1"}`
&toJsonPlaceholder=`myplaceholder`
]]
than you can use that placeholder in your snippet and do what you want with it.
-
- 24,544 Posts
Now THAT'S cool.
Add a :toFile custom output modifier and you're in business.
Or use runSnippet() in a plugin, like I do with my variation on CSSSweet.