I am trying to create a json output of all the articles data. When I try and output the articles using [[+articlestags]] its just a string with comma's seperating the items. I looked at the snippet "tolinks" which is great, but I am not much of a php coder.
If I could do this.
{
"tags" : "[[+articlestags]]",
}
and have the articlestags output proper json.
I thought about just making a migxtv variable and forgetting about articles.. i dont use any of the functionality. i just pull all the data and use it in a angular app. but if I did that I might as well just create my own resources and do the whole thing in migx and standard variables..
You could create a custom output modifier in the form of a snippet called ToJSON with this code:
return $modx->toJSON($input);
Once that exists, this should work:
"tags": "[[+articlestags:ToJSON]]",
If you want your JSON string to represent an array, you'll want this instead in the snippet:
$code = explode(',', $input);
return $modx->toJSON($code);