Open timkelty opened 10 years ago
I think this is a great idea, and I need this too.
i first just thought about quickly adding a snippet to rebuild_list(). e.g. if (tagparam('output_format')=='json') return json_encode($list);
then, actually, all you need is this in a quick plugin
public function json()
{
$this->EE = get_instance();
// Pass on the parameters to stash :-)
// name="listname" type="snippet" scope="site"
// match="#{segment_3}#" against="entry_id"
$params = $this->EE->TMPL->tagparams;
$list = Stash::rebuild_list($params);
return json_encode($list, JSON_PRETTY_PRINT);
}
Example:
Would render:
Example 2 (using same set as #1):
Would render:
Example 3:
Would render:
I for one, would get endless use out of this. Much of the stash wrangling I do is for output like this.
What would be really cool, is if you modularized each "output format" or provided a hook, so that others could make output format extensions themselves!