Ditto is a MODx content aggregation snippet that allows users to display and paginate collections of documents. It supports templating and outputs content in common formats like HTML, JSON, XML, Atom and RSS. Key parameters include &parents to set the parent documents, &depth for fetching level, &paginate for pagination, &display for number of documents per page, and placeholders like [+date+] that can be formatted and sourced from different document fields.
Ditto is a MODx content aggregation snippet that allows users to display and paginate collections of documents. It supports templating and outputs content in common formats like HTML, JSON, XML, Atom and RSS. Key parameters include &parents to set the parent documents, &depth for fetching level, &paginate for pagination, &display for number of documents per page, and placeholders like [+date+] that can be formatted and sourced from different document fields.
Ditto is a MODx content aggregation snippet that allows users to display and paginate collections of documents. It supports templating and outputs content in common formats like HTML, JSON, XML, Atom and RSS. Key parameters include &parents to set the parent documents, &depth for fetching level, &paginate for pagination, &display for number of documents per page, and placeholders like [+date+] that can be formatted and sourced from different document fields.
Pur: ID(s) of documents parent(s) Pur: number of current page as seen in URL query Opt: Comma-separated list of IDs string (?start=[+urlStart+]) Description : Aggregates documents to create blogs, Def: current document [+stop+] article/news collections, and more,with Not: Supersedes &startID (only 1 value) Pur: sequence number within complete set of last full support for templating. Rel: &documents, &depth displayed document on page Author : Mark Kaplan for MODx CMF &documents [+total+] Version : 2.1.0 Pur: ID(s) of documents Pur: total number of retrieved documents Opt: Any container/document folder [+pages+] Parameters Def: None Pur: page-number links to all the other pages, inactive Not: Overrides any setting in &parents display of current page number Rel: &parents, &depth [+currentPage+] &ditto_base &IDs Pur: number of current page Purpose: Location of Ditto files Option: Ditto's base path Pur: Internal variable which holds the set of IDs for [+perPage+] Default:[(base_path)]assets/snippets/ditto/ Ditto to fetch Pur: displayed items per page (equal to Note: Location includes trailing slash Opt: &parents | &document <strong>&display</strong>) Placeholders: - Def: &documents [+totalPages+] Related: - Not: if &idType==”parents”, it’ll set &parents Pur: total number of pages in result Rel: &parents, &documents, &idType &id [+ditto_pagination_set+] &depth Pur: Unique ID for connection with other scripts (such Pur: 1 if &paginate is set as Reflect) and for unique URL parameters Pur: document fetching level Opt: a-z, _, 0-9 Opt: positive integer &dateSource Def: "" - blank Def: 1 Not: Zero sets 'infinite depth' Pur: Source of the [+date+] placeholder Not: Case-sensitive Opt: Any UNIX timestamp from createdon, pub_date, Rel: &parents, &documents, &seeThruUnpub &language editedon, or other TVs &paginate Opt: $ditto_base/lang folder Def: [+createdon+] Def: english Pur: Paginate the results set into pages of &display Rel: &dateFormat length. Use &total to limit the number of documents &format &dateFormat retreived. Opt: html | json | xml | atom | rss Pur: Format the [+date+] placeholder in human Opt: 0 (off) | 1 (on) Def: html readable form Def: 0 &config Opt: Any PHP valid strftime option Rel: &paginateAlwaysShowLinks, Pur: Set parameters in a configuration file &paginateSplitterCharacter, &display, &total Def: $_lang["dateFormat"] Opt: default | CONFIG_NAME (configs folder or Rel: &dateSource &paginateAlwaysShowLinks @FILE) &display = &summarize Pur: Determine whether or not to always show Def: ”default” - default blank config file Pur: Number of documents to display (per page if previous next links Not: Store in ditto/configs folder as pagination is on) Opt: 0 (off) | 1 (on) <name>.config.php; can have pre-processing as well Opt: Number | `all` Def: 0 as parameters Def: `all` &paginateSplitterCharacter Rel: &extenders Not: Zero sets 'infinite depth' Pur: Splitter to use if always show is disabled &extenders Rel: &queryLimit, &total Opt: Any valid character Pur: extenders to adds Ditto’s function &total Def: $_lang['button_splitter'] Opt: extenders folder | @FILE Pur: Number of documents to retrieve &tplPaginatePrevious Def: [NULL] Opt: Number | `all` Rel: &config Pur: Template for the previous link Def: `all` Opt: {{chunk_name}} | @CODE | @FILE &extenders Rel: &queryLimit, &display PH: [+url+] | [+lang:previous+] Pur: Array that can be added to by configs or &showPublishedOnly &tplPaginateNext formats to load that extender Pur: Show only published documents Pur: Template for the next link &placeholders Opt: 0 - all | 1 – published only Opt: {{chunk_name}} | @CODE | @FILE Pur: Initialize custom placeholders array for configs Def: 1 PH: [+url+] | [+lang:next+] or extenders to add to Rel: &seeThruUnpub, &hideFolders, &where &tplPaginateNextOff &filters &showInMenuOnly Pur: Template for the inside of the next link Pur: Holds both the custom filters array for configs Pur: Show only visible in the menu Opt: {{chunk_name}} | @CODE | @FILE or extenders to add to and the parsed filters array. Opt: 0 - all | 1 – menu only PH: [+lang:next+] To add to this array, use the following format Def: 0 &tplPaginatePreviousOff $filters["parsed"][] = array("name" => Rel: &seeThruUnpub, &hideFolders, &where, Pur: Template for the previous link when it is off &hidePrivate array("source"=>$source,"value"=>$value,"mode Opt: {{chunk_name}} | @CODE | @FILE &hideFolders "=>$mode)); PH: [+lang:previous+] $filters["custom"][] = Pur: hide folders &tplPaginatePage array("source","callback_function"); Opt: 0 – keep folders | 1 – remove folders Pur: Template for the page link Def: 0 &orderBy Opt: {{chunk_name}} | @CODE | @FILE Pur: An array that holds all criteria to sort the result Rel: &seeThruUnpub, &showInMenuOnly, &where PH: [+url+] | [+page+] &hidePrivate set by. Note that using a custom sort will disable all &tplPaginateCurrentPage other sorting. Pur: hide docs from unauthorized web user Pur: Template for the current page link Opt: 0 – show | 1 – hide $orderBy["parsed"][] = Opt: {{chunk_name}} | @CODE | @FILE array("sortBy","sortDir"); Def: 1 PH: [+page+] Rel: &seeThruUnpub, &showInMenuOnly, &where $orderBy["custom"][] = array("sortBy","callback_function"); &seeThruUnpub Pur: show unpublished folders &children &idType pagination Placeholders Opt: 0 – hide | 1 – show Pur: type of IDs provided; can be either parents or Not: all pagination placeholders are empty if Def: 0 documents &paginate <> 1 Not: Used when &depth is greater than 1 Opt: documents | parents [+next+] Rel: &hideFolders, &showInMenuOnly, &where, Def: parents Pur: link to next page of result &depth &debug [+previous+] &where Pur: Output debugging information Pur: link to previous page of result Pur: Custom MySQL WHERE statement (instead of Opt: 0 (off) | 1 (on) [+splitter+] folder or document-based retrieval) Def: 0 Pur: filled with &paginateSplitterCharacter when Opt: A valid MySQL WHERE statement using only &phx [+previous+] and [+next+] are both active document fields (no TVs) Pur: Use PHx formatting [+start+] Def: empty Opt: 0 (off) | 1 (on) Pur: sequence number within complete set of first Rel: &queryLimit, &showPublishedOnly, Def: 1 displayed document on page &showInMenuOnly, &hidePrivate, &seeThruUnpub Ditto & Reflect Cheatsheet, rev. 1.0 |1 &queryLimit = &limit &globalFilterDelimiter Pur: chunk to format the last document Pur: Number of documents to retrieve from the Pur: If use different char than "|" to separate Opt: {{chunk_name}} | @CODE | @FILE database (= MySQL LIMIT ) clauses Def: &tpl Opt: Number | `0` - automatic Def: the pipe symbol ( "|" ) &tplCurrentDocument Def: ` 0` - automatic &localFilterDelimiter Pur: chunk to format the current document Not: Used with &where parameter only Pur: If use different char than "," to separate terms Opt: {{chunk_name}} | @CODE | @FILE Rel: &where, &total Def: comma ( "," ) Def: &tpl &noResults &keywords Pur: no result returning text Pur: fetching of associated keywords, from General Placeholders Opt: $_lang['no_documents'] | {{chunk}} | text [+keywords+] or as a tagData source Def: $_lang['no_documents'] Opt: 0 (off) | 1 (on) [+author+] &removeChunk Def: 0 Pur: First available of createdby->fullname, createdby- Pur: remove chunk(s), e.g.: comments &orderBy >username, admin username of retrieved document Opt: comma separated Pur: Order and direction by which to sort the results [+title+] Def: false Opt: Comma-separated list Pur: pagetitle field of retrieved document &hiddenFields Def: `createdon DESC` [+url+] Pur: retrieve unshown fields in template Not: Supersedes &sortBy and &sortDir Pur: link to retrieved document Opt: comma separated nested placeholders and &randomize [+ditto_iteration+] [*fields*] Pur: Randomize the order of the output Pur: sequence number of retrieved document within Def: false Opt: 0 (off) | 1 (on) current page &start = &offset Def: 0 Not: Starts from zero Pur: Number of documents to skip from starting list &save [+ditto_sort +] Opt: number Pur: Saves the ditto object and results set to Pur: sequence number of retrieved document within Def: 0 placeholders for use by other snippets complete retrieved set &filters Opt: 0 (off)-returns output | 1 (remaining)-returns Not: Starts from zero Pur: Removes items that match filter criteria output | 2 (save all) | 3 (save all)-returns placeholders Opt: `field,criteria,mode` with pipe (“|”) delimiter for only multiple filters Def: 0 Def: empty &tpl Mode: 1 is != | 2 is == | 3 is < | 4 is > | 5 is <= | 6 is >= Pur: chunk to format the documents | 7 does not contain the text of the criterion | 8 contains Opt: {{chunk_name}} | @CODE | @FILE the text of the criterion | 9 case insensitive version of Def: $_lang['default_template'] #7 | 10 case insensitive version of #8 | 11 checks &tplAlt leading character of the field Pur: chunk to format every other document Not: Ditto supports the @EVAL binding to evaluate Opt: {{chunk_name}} | @CODE | @FILE php expressions in filter clauses. Def: &tpl Eg: &tplFirst • &filter=`id,170,3|id,173,4` Pur: chunk to format the first document • &filter=`pagetitle,MODx,9` Opt: {{chunk_name}} | @CODE | @FILE • &filter=`createdon,@EVAL return strtotime('-1 Def: &tpl year');,6` &tplLast
Extenders
&extenders=`summary` summary Placeholders &month
Pur: Legacy support for the [+summary+] placeholder Pur: Month to filter by &trunc [+summary+] Opt: Number between 1-12 (inclusive) Pur: Enable truncation on the summary placeholder Pur: Content of introtext field, if not blank, or truncated Def: [NULL] Opt: 0 (off) | 1 (on) text &year Def: 1 [+link+] Pur: Year to filter by &truncAt Pur: Link to full item Opt: numerical year (4 numbers; ex: 2006) Pur: Location to split the content at Not: Link text set by &trunctText or default from Def: [NULL] Opt: Any unique text or code string language file &day Def: ”<!-- splitter -->” Pur: Day to filter by &truncLen &extenders=`dateFilter` Opt: numerical day within the current month Pur: Number of characters to show of the content Pur: Filtering companion to Reflect or other date Def: [NULL] Opt: Any number greater than truncOffset based filtering Def: 300 &dateFilterSource dateFilter Placeholders &truncOffset Pur: Source for the day, month, and year to filter by Pur: Number of charactars to “wander” either way of Opt: [+year+] truncLen get - gets the value of year, month, and day from the Pur: Year being filtered by Opt: Any number greater less than truncLen URL (pre-appended with the Ditto ID) [+month+] Def: 30 params - gets the value from the snippet cal Pur: Month being filtered by &truncText text - name of the request variable to use [+month_numeric+] Pur: Text to be displayed in [+link+] Def: get Pur: Numeric version of the month being filtered by Opt: Any valid text or html &dateSource [+day+] Def: ”Read more...” Pur: Source of the [+date+] placeholder Pur: Day being filtered by &tplTrunc Opt: Any UNIX timestamp from createdon, pub_date, Pur: Template to be used for [+link+] editedon, or other TVs Opt: {{chunk_name}} | @CODE | @FILE Def: [+createdon+] PH: Rel: &dateFormat [+url+] URL of the document &dateFilterDefault [+text+] &truncText Pur: Determine the default filter Def: &truncText Opt: 0 = filter off 1 = current year 2 = current year and month 3 = current year, month, and day Def: 0
Ditto & Reflect Cheatsheet, rev. 1.0 |2
&extenders=` request` Pur: Define a custom template for the tagLinks Pur: ID for archive links to point to Pur: Adds support for changing Ditto parameters via placeholder Opt: Any MODx document with a Ditto call setup with URL Opt: {{chunk_name}} | @CODE | @FILE extenders=`dateFilter` &stripTags Def: <a href="[+url+]" class="ditto_tag" Def: Current MODx Document Pur: Remove HTML tags from the parameters rel="tag">[+tag+]</a> &dateSource provided &tagCallback Pur: Date source to display for archive items Opt: 0 (off) | 1 (on) Pur: Allow the user to modify both where the tags Opt: Any UNIX timestamp from createdon, pub_date, Def: 1 come from and how they are parsed. editedon, or other TVs &bad Opt: Any valid function name Def: [+createdon+] Pur: Parameters that are not allowed to be set Not: The function should expect to receive the Rel: &dateFormat Opt: Any valid Ditto options separated by commas following three parameters: &dateFormat Def: ”seeThroughtUnpub, showInMenuOnly, • tagData - the provided source of the tags Pur: Format the [+date+] placeholder in human showPublishedOnly, debug, start, config, extenders, • resource - the resource array for the document readable form dittoID” being parsed Opt: Any PHP valid strftime option &good • array - return the results in an array if true Def: ”%d-%b-%y %H:%M” Pur: Parameters that are allowed to be set Def: [NULL] Rel: &dateSource Opt: Any valid Ditto options separated by commas &yearSortDir Def: All parameters except those in &bad Tagging Placeholders Pur: Direction to sort documents &dbg Opt: ASC – ascending | DESC - descending Pur: Output variables being set [+tagLinks+] Def: ”DESC” Opt: 0 (off) | 1 (on) Pur: Nice ‘n beautiful tag list with links pointing to &monthSortDir Def: 0 tagDocumentID Pur: Direction to sort the months [+tags+] Opt: ASC – ascending | DESC - descending Tagging extender Pur: Raw tags separated by tagDelimiter Def: ” ASC” Pur: Collection of parameters, functions, and classes Rel: &yearSortDir that expand Ditto’s functionality to include tagging &start Not: automatically included when using the &tagData parameter to indicate a field that contains tag data. Reflect Pur: Number of documents to skip in the results Opt: Any number &tagDocumentID Description : Generates date based archives using Def: 0 Pur: ID for tag links to point to Ditto &phx Opt: Any MODx document with a Ditto call setup to Author : Mark Kaplan for MODx CMF Pur: Use PHx formatting receive the tags Version : 2.1.0 Opt: 0 (off) | 1 (on) Def: Current document Note : If Reflect is not retrieving its own Def: 1 &tagData documents, make sure that the Ditto call ¶ms Pur: Field to get the tags from, usually name a feeding it has all of the fields in it that you Pur: Pass parameters to the Ditto instance used to template variable plan on calling in your Reflect template. retreive the documents Opt: Comma separated list of fields or TVs Furthermore, Reflect will ONLY show Opt: Any valid ditto parameters in the format Def: [NULL] what is currently in the Ditto result set. name:value with multiple parameters separated by a &caseSensitive Thus, if pagination is on it will ONLY pipe (“|”) Opt: 0 (off) | 1 (on) show that page’s items. Not: This parameter is only needed for config, Def: 0 start, and phx as you can now simply use the &tagMode Parameters parameter as if Reflect was Ditto Pur: Filtering method to remove tags Def: [NULL] Opt: &source &reflect_base • onlyAllTags - show documents that have all of the Pur: Name of the Ditto snippet to use Purpose: Location of Reflect files Opt: Any valid snippet name tags Option: Reflect's base path Def: ”Ditto” • onlyTags - show documents that have any of the Default:[(base_path)]assets/snippets/reflect/ tags &tplContainer Note: Location includes trailing slash • removeAllTags - remove documents that have all Pur: Container template for the archive Placeholders: - of the tags Opt: {{chunk_name}} | @CODE | @FILE Related: - • removeTags - documents that have any of the tags Def: See default.templates.php &id Def: ”onlyTags” &tplYear Pur: Unique ID for connection with other scripts (such &tagDelimiter Pur: Template for the year item as Reflect) and for unique URL parameters Pur: Delimiter that splits each tag in the tagData Opt: {{chunk_name}} | @CODE | @FILE Opt: a-z, _, 0-9 source Def: See default.templates.php Def: "" - blank Opt: Any character not included in the tags Not: Case-sensitive &tplYearInner themselves &config Pur: Template for the year item (the ul to hold the year Def: ” “ - space template) Pur: Load a custom configuration &tagDisplayDelimiter Opt: {{chunk_name}} | @CODE | @FILE Opt: default | wordpress | CONFIG_NAME (configs Pur: What separates the tags in [+tagLinks+] Def: See default.templates.php folder or @FILE) Opt: Any character Def: ”default” - default blank config file &tplMonth Def: &tagDelimiter Not: Store in reflect/configs folder as Pur: Template for the month item &tagSort <name>.config.php; can have pre-processing as well Opt: {{chunk_name}} | @CODE | @FILE Pur: Sort the tags alphanumerically as parameters Def: See default.templates.php Opt: 0 (off) | 1 (on) Rel: &extenders &tplMonthInner Def: 1 &getDocuments Pur: Template for the month item (the ul to hold the &tagDisplayMode Pur: Force Reflect to get documents month template) Pur: How to display the tags in [+tagLinks+] Opt: 0 (off) | 1 (on) Opt: {{chunk_name}} | @CODE | @FILE Opt: Def: 0 Def: See default.templates.php 1 - string of links &tagDisplayDelimiter separated &showItems &tplItem 2 - ul/li list Pur: Show individual items in the archive Pur: Template for the individual item Def: 1 Opt: 0 (off) | 1 (on) Opt: {{chunk_name}} | @CODE | @FILE &tags Def: 1 Def: See default.templates.php Pur: Allow the user to provide initial tags to be filtered &groupByYears Opt: Any valid tags separated by tagDelimiter Pur: Group the archive by years Def: [NULL] Opt: 0 (off) | 1 (on) &tplTagLinks Def: 1 &targetID