That’s just it, Ditto can be used in various circumstances when you need to retrieve documents.
I look at Ditto just as a snippet that can retrieve documents in different forms.. And as you know, documents in modx can be just about whatever, image gallery items, webshop items, blog posts / comments, calendar events etc etc.. I’ve recently used Ditto in a
GoogleMap snippet where you can do pins to the map as documents. I used Ditto to retrieve the markers as a javascript code (just made a chunk template what spills out javascript function calls with certain parameters).
And ditto can also output in JSON format (but currently there’s no ability to make "json template" or have TV’s in it). Kylej used that in the
DittoCal snippet.
It get’s even easier in the upcoming Ditto version to use it inside another snippet because now you can pass the template code to use in the snippet call (no need to have it in a chunk). And there is also plans for an customizable XML output format.
but to get for example the playlist from ditto (
1.0.3 beta) as xml, you could do
some thing like this in your snippet (some what copy pasted from GoogleMapMarker):
<?php
// [number]
// The ID number of the top folder that has google marker documents
$startID = (isset($startID)) ? $startID : "";
// [number]
// Number of levels deep to go
$descendentDepth = (isset($descendentDepth)) ? $descendentDepth : 1;
// [text]
// Field to sort by (recommended values include createdon, pub_date, editedon)
$sortBy = (isset($sortBy)) ? $sortBy : "createdon";
// ["DESC" | "ASC"]
// Direction to sort by, either ASC (ascending) or DESC (descending)
$sortDir = (isset($sortDir)) ? $sortDir : "ASC";
$dittoChunk = '<track>
<location>[(site_url)][*tvMP3File*]</location>
<image>[(site_url)][*tvAlbumCover*]</image>
<annotation>[*pagetitle*]</annotation>
</track>';
$output = '<?xml version="1.0" encoding="UTF-8" ? ><playlist version="0" xmlns = "http://xspf.org/ns/0/"><trackList>';
$output .= $modx->runSnippet("Ditto",array('descendentDepth' => $descendentDepth, 'sortBy' => $sortBy, 'sortDir' => $sortDir, 'summarize' => 'all', 'displayArchive' => '0', 'tpl' => $dittoChunk, 'startID' => $startID, 'showPublishedOnly' => '0', 'trunc' => '0'));
$output .= '</trackList></playlist>';
return $output;
?>
Note that I put spaces in the end of <?xml?> tag so it would color the whole code..
So.. did it become any clearer for you? I don’t know what more I could/should write. Please, feel free to ask more if there is still something that you wonder..