Aggregates documents to create blogs, article/news collections, and more,with full support for templating.
Mark Kaplan for MODx CMF
2.1.0
| Ditto Snippet | Aggregates documents to create blogs, article/news collections, and more,with full support for templating. |
| Parameters | |
| ditto_base | Location of Ditto files |
| id | Unique ID for this Ditto instance for connection with other scripts (like Reflect) and unique URL parameters |
| language | language for defaults, debug, and error messages |
| format | Output format to use |
| config | Load a custom configuration |
| debug | Output debugging information |
| phx | Use PHx formatting |
| extenders | Load an extender which adds functionality to Ditto |
| Variables | |
| extenders | Array that can be added to by configs or formats to load that extender |
| placeholders | Initialize custom placeholders array for configs or extenders to add to |
| filters | Holds both the custom filters array for configs or extenders to add to and the parsed filters array. |
| orderBy | An array that holds all criteria to sort the result set by. |
| idType | type of IDs provided; can be either parents or documents |
| Parameters | |
| parents | IDs of containers for Ditto to retrieve their children to &depth depth |
| documents | IDs of documents for Ditto to retrieve |
| Variables | |
| IDs | Internal variable which holds the set of IDs for Ditto to fetch |
| Parameters | |
| depth | Number of levels deep to retrieve documents |
| paginate | Paginate the results set into pages of &display length. |
| dateSource | Source of the [+date+] placeholder |
| dateFormat | Format the [+date+] placeholder in human readable form |
| display | Number of documents to display in the results |
| total | Number of documents to retrieve |
| showPublishedOnly | Show only published documents |
| showInMenuOnly | Show only documents visible in the menu |
| hideFolders | Don’t show folders in the returned results |
| hidePrivate | Don’t show documents the guest or user does not have permission to see |
| seeThruUnpub | See through unpublished folders to retrive their children Used when depth is greater than 1 |
| queryLimit | Number of documents to retrieve from the database, same as MySQL LIMIT |
| where | Custom MySQL WHERE statement |
| noResults | Text or chunk to display when there are no results |
| removeChunk | Name of chunks to be stripped from content separated by commas |
| hiddenFields | Allow Ditto to retrieve fields its template parser cannot handle such as nested placeholders and [fields] |
| start | Number of documents to skip in the results |
| globalFilterDelimiter | Filter delimiter used to separate filters in the filter string |
| localFilterDelimiter | Delimiter used to separate individual parameters within each filter string |
| filter | Removes items not meeting a critera. |
| keywords | Enable fetching of associated keywords for each document Can be used as [+keywords+] or as a tagData source |
| randomize | Randomize the order of the output |
| save | Saves the ditto object and results set to placeholders for use by other snippets |
| tpl | User defined chunk to format the documents |
| tplAlt | User defined chunk to format every other document |
| tplFirst | User defined chunk to format the first document |
| tplLast | User defined chunk to format the last document |
| tplCurrentDocument | User defined chunk to format the current document |
| orderBy | Sort the result set |
| paginateAlwaysShowLinks | Determine whether or not to always show previous next links |
| paginateSplitterCharacter | Splitter to use if always show is disabled |
| tplPaginatePrevious | Template for the previous link |
| tplPaginateNext | Template for the next link |
| tplPaginateNextOff | Template for the inside of the next link |
| tplPaginatePreviousOff | Template for the previous link when it is off |
| tplPaginatePage | Template for the page link |
| tplPaginateCurrentPage | Template for the current page link |
| Placeholders | |
| item[x] | Individual items rendered output |
Location of Ditto files
Any valid folder location containing the Ditto source code with a trailing slash
[(base_path)]assets/snippets/ditto/
Unique ID for this Ditto instance for connection with other scripts (like Reflect) and unique URL parameters
Any combination of characters a-z, underscores, and numbers 0-9
This is case sensitive
| ”” | blank |
language for defaults, debug, and error messages
Any language name with a corresponding file in the &ditto_base/lang folder
”english”
Load a custom configuration
| ”default” | default blank config file |
| CONFIG_NAME | Other configs installed in the configs folder or in any folder within the MODx base path via @FILE |
”default”
Load an extender which adds functionality to Ditto
Any extender in the extenders folder or in any folder within the MODx base path via @FILE
[NULL]
Holds both the custom filters array for configs or extenders to add to and the parsed filters array. To add to this array, use the following format
$filters["parsed"][] = array("name" => array("source"=>$source,"value"=>$value,"mode"=>$mode));
$filters["custom"][] = array("source","callback_function");An array that holds all criteria to sort the result set by. Note that using a custom sort will disable all other sorting.
$orderBy["parsed"][] = array("sortBy","sortDir");
$orderBy["custom"][] = array("sortBy","callback_function");IDs of documents for Ditto to retrieve
Any valid MODx document marked as a container
None
Number of levels deep to retrieve documents
Any number greater than or equal to 1 0 - infinite depth
1
Paginate the results set into pages of &display length. Use &total to limit the number of documents retreived.
| 0 | off |
| 1 | on |
| 0 | off |
Source of the [+date+] placeholder
| # | Any UNIX timestamp from MODx fields or TVs such as createdon, pub_date, or editedon |
”createdon”
Format the [+date+] placeholder in human readable form
Any PHP valid strftime option
[LANG]
Number of documents to display in the results
| # | Any number |
| ”all” | All documents found |
3
Number of documents to retrieve
| # | Any number |
| ”all” | All documents found |
| ”all” | All documents found |
Show only published documents
| 0 | show only unpublished documents |
| 1 | show both published and unpublished documents |
| 1 | show only published documents |
Show only documents visible in the menu
| 0 | show all documents |
| 1 | show only documents with the show in menu flag checked |
| 0 | show all documents |
Don’t show folders in the returned results
| 0 | keep folders |
| 1 | remove folders |
| 0 | keep folders |
Don’t show documents the guest or user does not have permission to see
| 0 | show private documents |
| 1 | hide private documents |
| 1 | hide private documents |
See through unpublished folders to retrive their children Used when depth is greater than 1
| 0 | off |
| 1 | on |
| 0 | off |
Number of documents to retrieve from the database, same as MySQL LIMIT
| # | Any number |
| 0 | automatic |
| 0 | automatic |
Custom MySQL WHERE statement
A valid MySQL WHERE statement using only document object items (no TVs)
[NULL]
Text or chunk to display when there are no results
Any valid chunk name or text
[LANG]
Name of chunks to be stripped from content separated by commas
Any valid chunkname that appears in the output
[NULL]
Allow Ditto to retrieve fields its template parser cannot handle such as nested placeholders and [fields]
Any valid MODx fieldnames or TVs comma separated
[NULL]
Filter delimiter used to separate filters in the filter string
Any character not used in the filters
”|”
Delimiter used to separate individual parameters within each filter string
Any character not used in the filter itself
”,”
Removes items not meeting a critera. Thus, if pagetitle == joe then it will be removed. Use in the format field,criteria,mode with the comma being the local delimiter
Mode Meaning
| 1 | != |
| 2 | == |
| 3 | < |
| 4 | > |
| 5 | <= |
| 6 | >= |
| 7 | Text not in field value |
| 8 | Text in field value |
| 9 | case insenstive version of #7 |
| 10 | case insenstive version of #8 |
| 11 | checks leading character of the field |
@EVAL in filters works the same as it does in MODx exect it can only be used with basic filtering, not custom filtering (tagging, etc). Make sure that you return the value you wish Ditto to filter by and that the code is valid PHP.
[NULL]
Enable fetching of associated keywords for each document Can be used as [+keywords+] or as a tagData source
| 0 | off |
| 1 | on |
| 0 | off |
Randomize the order of the output
| 0 | off |
| 1 | on Any MODx field or TV for weighted random |
| 0 | off |
Saves the ditto object and results set to placeholders for use by other snippets
| 0 | off; returns output |
| 1 | remaining; returns output |
| 2 | all; |
| 3 | all; returns ph only |
| 0 | off; returns output |
User defined chunk to format the documents
[LANG]
User defined chunk to format every other document
&tpl
User defined chunk to format the first document
&tpl
User defined chunk to format the last document
&tpl
User defined chunk to format the current document
&tpl
Sort the result set
Any valid MySQL style orderBy statement
createdon DESC
Determine whether or not to always show previous next links
| 0 | off |
| 1 | on |
| 0 | off |
Splitter to use if always show is disabled
Any valid character
[LANG]
Template for the previous link
| url | URL for the previous link |
| lang:previous | value of ‘prev’ from the language file |
Template for the next link
| url | URL for the next link |
| lang:next | value of ‘next’ from the language file |
Template for the inside of the next link
| lang:next | value of ‘next’ from the language file |
Template for the previous link when it is off
| lang:previous | value of ‘prev’ from the language file |
Template for the page link
| url | url for the page |
| page | number of the page |
Split up the filters into an array and add the required fields to the fields array
function parseFilters( $filter = false, $cFilters = false, $pFilters = false, $globalDelimiter, $localDelimiter )