Download - MODx Ditto Snippet Documentation
Description
Aggregates documents to create blogs, article/news collections,and more,with full support for templating.
Author
Mark Kaplan for MODx CMF
Version
2.1.0
Summary
Ditto Snippet Aggregates documents tocreate blogs, article/newscollections, and more,withfull support for templating.
Parameters
ditto_base Location of Ditto files
id Unique ID for this Ditto instancefor connection with other scripts(like Reflect) and unique URLparameters
language language for defaults, debug, anderror messages
format Output format to use
config Load a custom configuration
debug Output debugging information
phx Use PHx formatting
extenders Load an extender which addsfunctionality to Ditto
Variables
extenders Array that can be added to byconfigs or formats to load thatextender
placeholders Initialize custom placeholdersarray for configs or extenders toadd to
filters Holds both the custom filters arrayfor configs or extenders to add toand the parsed filters array.
orderBy An array that holds all criteria tosort the result set by.
idType type of IDs provided; can be eitherparents or documents
Welcome
Snippet
Snippet
Wordpress Config
Template Class
ATOM
JSON
XML
Summary
Tagging
1 of 22
Parameters
parents IDs of containers for Ditto toretrieve their children to &depthdepth
documents IDs of documents for Ditto toretrieve
Variables
IDs Internal variable which holds theset of IDs for Ditto to fetch
Parameters
depth Number of levels deep to retrievedocuments
paginate Paginate the results set into pagesof &display length.
dateSource Source of the [+date+]placeholder
dateFormat Format the [+date+] placeholderin human readable form
display Number of documents to display inthe results
total Number of documents to retrieve
showPublishedOnly Show only published documents
showInMenuOnly Show only documents visible in themenu
hideFolders Don’t show folders in the returnedresults
hidePrivate Don’t show documents the guestor user does not have permissionto see
seeThruUnpub See through unpublished folders toretrive their children Used whendepth is greater than 1
queryLimit Number of documents to retrievefrom the database, same asMySQL LIMIT
where Custom MySQL WHERE statement
noResults Text or chunk to display whenthere are no results
removeChunk Name of chunks to be strippedfrom content separated bycommas
hiddenFields Allow Ditto to retrieve fields itstemplate parser cannot handlesuch as nested placeholders and[fields]
start Number of documents to skip inthe results
globalFilterDelimiter Filter delimiter used to separatefilters in the filter string
localFilterDelimiter Delimiter used to separateindividual parameters within eachfilter string
2 of 22
filter Removes items not meeting acritera.
keywords Enable fetching of associatedkeywords for each document Canbe used as [+keywords+] or as atagData source
randomize Randomize the order of the output
save Saves the ditto object and resultsset to placeholders for use byother snippets
tpl User defined chunk to format thedocuments
tplAlt User defined chunk to formatevery other document
tplFirst User defined chunk to format thefirst document
tplLast User defined chunk to format thelast document
tplCurrentDocument User defined chunk to format thecurrent document
orderBy Sort the result set
paginateAlwaysShowLinks Determine whether or not toalways show previous next links
paginateSplitterCharacter Splitter to use if always show isdisabled
tplPaginatePrevious Template for the previous link
tplPaginateNext Template for the next link
tplPaginateNextOff Template for the inside of the nextlink
tplPaginatePreviousOff Template for the previous linkwhen it is off
tplPaginatePage Template for the page link
tplPaginateCurrentPage Template for the current page link
Placeholders
item[x] Individual items rendered output
ditto_base
Purpose
Location of Ditto files
Options
Any valid folder location containing the Ditto source code witha trailing slash
Default
3 of 22
[(base_path)]assets/snippets/ditto/
id
Purpose
Unique ID for this Ditto instance for connection with otherscripts (like Reflect) and unique URL parameters
Options
Any combination of characters a-z, underscores, and numbers0-9
Note
This is case sensitive
Default
”” blank
language
Purpose
language for defaults, debug, and error messages
Options
Any language name with a corresponding file in the&ditto_base/lang folder
Default
”english”
format
Purpose
Output format to use
Options
”html””json””xml””atom””rss”
Default
4 of 22
”html”
config
Purpose
Load a custom configuration
Options
”default” default blank config file
CONFIG_NAME Other configs installed in the configsfolder or in any folder within theMODx base path via @FILE
Default
”default”
Related
extenders
debug
Purpose
Output debugging information
Options
0 off
1 on
Default
0 off
Related
debug
phx
Purpose
Use PHx formatting
Options
0 off
5 of 22
1 on
Default
1 on
extenders
Purpose
Load an extender which adds functionality to Ditto
Options
Any extender in the extenders folder or in any folder withinthe MODx base path via @FILE
Default
[NULL]
Related
config
Variables
extenders
Array that can be added to by configs or formats to load thatextender
placeholders
Initialize custom placeholders array for configs or extendersto add to
filters
Holds both the custom filters array for configs or extenders toadd to and the parsed filters array. To add to this array, use thefollowing format
$filters["parsed"][] = array("name" => array("source"=>$source,$filters["custom"][] = array("source","callback_function");
6 of 22
orderBy
An array that holds all criteria to sort the result set by. Notethat using a custom sort will disable all other sorting.
$orderBy["parsed"][] = array("sortBy","sortDir");$orderBy["custom"][] = array("sortBy","callback_function");
idType
type of IDs provided; can be either parents or documents
parents
Purpose
IDs of containers for Ditto to retrieve their children to &depthdepth
Options
Any valid MODx document marked as a container
Default
Current MODx Document
Related
documentsdepth
documents
Purpose
IDs of documents for Ditto to retrieve
Options
Any valid MODx document marked as a container
Default
None
7 of 22
Related
parents
Variables
IDs
Internal variable which holds the set of IDs for Ditto to fetch
depth
Purpose
Number of levels deep to retrieve documents
Options
Any number greater than or equal to 1 0 - infinite depth
Default
1
Related
seeThruUnpub
8 of 22
paginate
Purpose
Paginate the results set into pages of &display length. Use&total to limit the number of documents retreived.
Options
0 off
1 on
Default
0 off
Related
paginateAlwaysShowLinkspaginateSplitterCharacterdisplay
dateSource
Purpose
Source of the [+date+] placeholder
Options
# Any UNIX timestamp from MODx fields or TVssuch as createdon, pub_date, or editedon
Default
”createdon”
Related
dateFormat
dateFormat
Purpose
Format the [+date+] placeholder in human readable form
Options
Any PHP valid strftime option
Default
[LANG]
9 of 22
Related
dateSource
display
Purpose
Number of documents to display in the results
Options
# Any number
”all” All documents found
Default
3
Related
queryLimittotal
total
Purpose
Number of documents to retrieve
Options
# Any number
”all” All documents found
Default
”all” All documents found
Related
displayqueryLimit
showPublishedOnly
Purpose
Show only published documents
Options
0 show only unpublished documents
10 of 22
1 show both published and unpublisheddocuments
Default
1 show only published documents
Related
seeThruUnpubhideFoldersshowPublishedOnlywhere
showInMenuOnly
Purpose
Show only documents visible in the menu
Options
0 show all documents
1 show only documents with the show in menuflag checked
Default
0 show all documents
Related
seeThruUnpubhideFolderswhere
11 of 22
hideFolders
Purpose
Don’t show folders in the returned results
Options
0 keep folders
1 remove folders
Default
0 keep folders
Related
seeThruUnpubshowInMenuOnlywhere
hidePrivate
Purpose
Don’t show documents the guest or user does not havepermission to see
Options
0 show private documents
1 hide private documents
Default
1 hide private documents
Related
seeThruUnpubshowInMenuOnlywhere
seeThruUnpub
Purpose
See through unpublished folders to retrive their children Usedwhen depth is greater than 1
Options
0 off
1 on
12 of 22
Default
0 off
Related
hideFoldersshowInMenuOnlywhere
queryLimit
Purpose
Number of documents to retrieve from the database, same asMySQL LIMIT
Options
# Any number
0 automatic
Default
0 automatic
Related
where
where
Purpose
Custom MySQL WHERE statement
Options
A valid MySQL WHERE statement using only document objectitems (no TVs)
Default
[NULL]
Related
queryLimit
noResults
Purpose
Text or chunk to display when there are no results
13 of 22
Options
Any valid chunk name or text
Default
[LANG]
removeChunk
Purpose
Name of chunks to be stripped from content separated bycommas
Commonly used to remove comments
Options
Any valid chunkname that appears in the output
Default
[NULL]
hiddenFields
Purpose
Allow Ditto to retrieve fields its template parser cannothandle such as nested placeholders and [fields]
Options
Any valid MODx fieldnames or TVs comma separated
Default
[NULL]
start
Purpose
Number of documents to skip in the results
Options
Any number
Default
14 of 22
0
globalFilterDelimiter
Purpose
Filter delimiter used to separate filters in the filter string
Options
Any character not used in the filters
Default
”|”
Related
localFilterDelimiterfilterparseFilters
localFilterDelimiter
Purpose
Delimiter used to separate individual parameters within eachfilter string
Options
Any character not used in the filter itself
Default
”,”
Related
globalFilterDelimiterfilterparseFilters
filter
Purpose
Removes items not meeting a critera. Thus, if pagetitle ==joe then it will be removed. Use in the format field,criteria,modewith the comma being the local delimiter
Mode Meaning
15 of 22
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
@EVAL in filters works the same as it does in MODx exect itcan only be used with basic filtering, not custom filtering(tagging, etc). Make sure that you return the value you wishDitto to filter by and that the code is valid PHP.
Default
[NULL]
Related
localFilterDelimiterglobalFilterDelimiterparseFilters
keywords
Purpose
Enable fetching of associated keywords for each documentCan be used as [+keywords+] or as a tagData source
Options
0 off
1 on
Default
0 off
randomize
Purpose
Randomize the order of the output
16 of 22
Options
0 off
1 on Any MODx field or TV for weighted random
Default
0 off
save
Purpose
Saves the ditto object and results set to placeholders for useby other snippets
Options
0 off; returns output
1 remaining; returns output
2 all;
3 all; returns ph only
Default
0 off; returns output
tpl
Purpose
User defined chunk to format the documents
Options
Any valid chunk nameCode via @CODEFile via @FILE
Default
[LANG]
tplAlt
Purpose
User defined chunk to format every other document
Options
Any valid chunk name
17 of 22
Code via @CODEFile via @FILE
Default
&tpl
tplFirst
Purpose
User defined chunk to format the first document
Options
Any valid chunk nameCode via @CODEFile via @FILE
Default
&tpl
tplLast
Purpose
User defined chunk to format the last document
Options
Any valid chunk nameCode via @CODEFile via @FILE
Default
&tpl
18 of 22
tplCurrentDocument
Purpose
User defined chunk to format the current document
Options
Any valid chunk nameCode via @CODEFile via @FILE
Default
&tpl
orderBy
Purpose
Sort the result set
Options
Any valid MySQL style orderBy statement
Default
createdon DESC
paginateAlwaysShowLinks
Purpose
Determine whether or not to always show previous next links
Options
0 off
1 on
Default
0 off
Related
paginatepaginateSplitterCharacter
paginateSplitterCharacter
19 of 22
Purpose
Splitter to use if always show is disabled
Options
Any valid character
Default
[LANG]
Related
paginatepaginateSplitterCharacter
tplPaginatePrevious
Purpose
Template for the previous link
Options
Any valid chunk nameCode via @CODEFile via @FILE
Placeholders
url URL for the previous link
lang:previous value of ‘prev’ from the languagefile
Related
tplPaginateNextpaginateSplitterCharacter
tplPaginateNext
Purpose
Template for the next link
Options
Any valid chunk nameCode via @CODEFile via @FILE
Placeholders
url URL for the next link
lang:next value of ‘next’ from the language file
20 of 22
Related
tplPaginatePreviouspaginateSplitterCharacter
tplPaginateNextOff
Purpose
Template for the inside of the next link
Options
Any valid chunk nameCode via @CODEFile via @FILE
Placeholders
lang:next value of ‘next’ from the language file
Related
tplPaginatePreviouspaginateSplitterCharacter
tplPaginatePreviousOff
Purpose
Template for the previous link when it is off
Options
Any valid chunk nameCode via @CODEFile via @FILE
Placeholders
lang:previous value of ‘prev’ from the languagefile
Related
tplPaginatePreviouspaginateSplitterCharacter
tplPaginatePage
Purpose
Template for the page link
Options
Any valid chunk name
21 of 22
Code via @CODEFile via @FILE
Placeholders
url url for the page
page number of the page
Related
tplPaginatePreviouspaginateSplitterCharacter
tplPaginateCurrentPage
Purpose
Template for the current page link
Options
Any valid chunk nameCode via @CODEFile via @FILE
Placeholders
page number of the page
Related
tplPaginatePreviouspaginateSplitterCharacter
item[x]
Content
Individual items rendered output
Generated by Natural Docs
22 of 22
Purpose
The Ditto class contains all functions relating to Ditto’sfunctionality and any supporting functions they need
Summary
Main Class The Ditto class containsall functions relating toDitto’s functionality andany supporting functionsthey need
Functions
getTVList Get a list of all available TVs
addField Add a field to the internal fielddetection system
addFields Add a field to the internal fielddetection system from anarray or delimited string
removeField Remove a field to the internalfield detection system
setDisplayFields Move the detected fields intothe Ditto fields array
getDocVarType Determine if the providedfield is a tv, a database field,or something else
parseOrderBy Parse out orderBy parameterstring
checkAdvSort Check the advSortString
parseFilters Split up the filters into anarray and add the requiredfields to the fields array
render Render the document output
parseFields Find the fields that arecontained in the customplaceholders or those that areneeded in other functions
arrayUnique Make fields array unique
parseCustomPlaceholders Parse the required fields outof the custom placeholders
parseDBFields Parse out the fields requiredfor each state
renderQELinks Render QE links when needed
Welcome
Snippet
Snippet
Wordpress Config
Main Class
Template Class
ATOM
JSON
XML
Summary
Tagging
1 of 10
getAuthor Get the author name, or if notavailable the username
customSort Sort resource array ifadvanced sorting is needed
userSort Sort the resource array by auser defined function
multiSort Sort the resource array bymultiple fieldsRows->Columns portion byJon L.
determineIDs Get Document IDs for futureuse
weightedRandom Execute a random order sort
getParentList Get a list of all availableparents
appendTV Apeend a TV to thedocuments array
appendKeywords Append keywords’s to theresource array
fetchKeywords Helper function toappendKeywords
getChildIDs Get the IDs ready to beprocessed Similar to themodx version by the samename but much faster
getDocuments Get documents and appendTVs + Prefetch Data, and sort
getDocumentsLite Get an array of documents
cleanIDs Clean the IDs of anydangerous characters
buildURL Build a URL with regard toDitto ID
getParam Get a parameter or use thedefault language value
paginate Paginate the documents
noResults Render the noResults output
relToAbs Convert relative urls toabsolute URLs Based on scriptfromhttp://wintermute.com.au/bits/2005-09/php-relative-absolute-links/
getTVList
2 of 10
function getTVList()
Get a list of all available TVs
addField
function addField($name, $location, $type = false)
Add a field to the internal field detection system
addFields
function addFields($fields, $location = '*',$delimiter = ',',$callback = false)
Add a field to the internal field detection system from anarray or delimited string
removeField
function removeField($name,$location,$type )
Remove a field to the internal field detection system
setDisplayFields
function setDisplayFields($fields,$hiddenFields)
Move the detected fields into the Ditto fields array
3 of 10
getDocVarType
function getDocVarType($field)
Determine if the provided field is a tv, a database field,or something else
parseOrderBy
function parseOrderBy($orderBy,$randomize)
Parse out orderBy parameter string
checkAdvSort
function checkAdvSort($sortBy, $sortDir = 'asc')
Check the advSortString
parseFilters
function parseFilters($filter = false,$cFilters = false,$pFilters = false,$globalDelimiter, $localDelimiter )
Split up the filters into an array and add the requiredfields to the fields array
render
function render($resource, $template,
4 of 10
$removeChunk, $dateSource, $dateFormat, $ph = array(),$phx = 1,$x = 0 )
Render the document output
parseFields
function parseFields($placeholders,$seeThruUnpub,$dateSource,$randomize )
Find the fields that are contained in the customplaceholders or those that are needed in other functions
arrayUnique
function arrayUnique($array)
Make fields array unique
parseCustomPlaceholders
function parseCustomPlaceholders($placeholders)
Parse the required fields out of the custom placeholders
parseDBFields
function parseDBFields($seeThruUnpub)
Parse out the fields required for each state
5 of 10
renderQELinks
function renderQELinks($fields,$resource,$QEPrefix,$placeholders)
Render QE links when needed
getAuthor
function getAuthor($createdby)
Get the author name, or if not available the username
customSort
function customSort($data,$fields,$order )
Sort resource array if advanced sorting is needed
userSort
function userSort($resource,$sort )
Sort the resource array by a user defined function
multiSort
function multiSort($resource,$orderBy )
Sort the resource array by multiple fieldsRows->Columns portion by Jon L. -- [email protected]
6 of 10
Link: http://de3.php.net/manual/en/function.array-multisort.php#73498
determineIDs
function determineIDs($IDs,$IDType,$TVs,$orderBy,$depth,$showPublishedOnly,$seeThruUnpub,$hideFolders,$hidePrivate,$showInMenuOnly,$myWhere,$keywords,$dateSource,$limit,$summarize,$filter,$paginate,$randomize )
Get Document IDs for future use
weightedRandom
function weightedRandom($resource,$field,$show )
Execute a random order sort
getParentList
function getParentList()
Get a list of all available parents
appendTV
7 of 10
function appendTV($tvname = "",$docIDs )
Apeend a TV to the documents array
appendKeywords
function appendKeywords($resource)
Append keywords’s to the resource array
fetchKeywords
function fetchKeywords($resource)
Helper function to appendKeywords
getChildIDs
function getChildIDs($IDs,$depth)
Get the IDs ready to be processed Similar to the modxversion by the same name but much faster
getDocuments
function getDocuments($ids = array(),
$fields, $TVs, $orderBy, $published = 1,$deleted = 0,$public = 1,$where = '',$limit = "",$keywords = 0,$randomize = 0,
8 of 10
$dateSource = false)
Get documents and append TVs + Prefetch Data, and sort
getDocumentsLite
Get an array of documents
cleanIDs
function cleanIDs($IDs)
Clean the IDs of any dangerous characters
buildURL
function buildURL($args, $id = false,$dittoIdentifier = false )
Build a URL with regard to Ditto ID
getParam
function getParam($param,$langString)
Get a parameter or use the default language value
paginate
function paginate($start,$stop,$total,
9 of 10
$summarize,$tplPaginateNext,$tplPaginatePrevious,$tplPaginateNextOff,$tplPaginatePreviousOff,$tplPaginatePage,$tplPaginateCurrentPage,$paginateAlwaysShowLinks,$paginateSplitterCharacter)
Paginate the documents
noResults
function noResults($text,$paginate)
Render the noResults output
relToAbs
function relToAbs($text,$base )
Convert relative urls to absolute URLs Based on scriptfrom http://wintermute.com.au/bits/2005-09/php-relative-absolute-links/
Generated by Natural Docs
10 of 10
Template Class
Purpose
The Template class contains all functions relating to Ditto’shandling of templates and any supporting functions theyneed
Summary
Template Class The Template class contains allfunctions relating to Ditto’shandling of templates and anysupporting functions they need
Functions
template Set the class language and fieldsvariables
process Take the templates and parse themfor tempalte variables, Check tomake sure they have fields, and sortthe fields
findTemplateVars Find al the template variables in thetemplate
sortFields Sort the array of fields provided bytype
replace Replcae placeholders with theirvalues
determine Determine the correct template toapply
fetch Get a template, based on version byDoze
get_file_contents Returns the contents of file namepassed
template
function template()
Set the class language and fields variables
Welcome
Snippet
Snippet
Wordpress Config
Template Class
ATOM
JSON
XML
Summary
Tagging
1 of 3
process
function process($template)
Take the templates and parse them for tempaltevariables, Check to make sure they have fields, and sort thefields
findTemplateVars
function findTemplateVars($tpl)
Find al the template variables in the template
sortFields
function sortFields ($fieldList)
Sort the array of fields provided by type
replace
function replace($placeholders,$tpl )
Replcae placeholders with their values
2 of 3
determine
function determine($templates,$x,$start,$stop,$id )
Determine the correct template to apply
fetch
function fetch($tpl)
Get a template, based on version by Doze
http://modxcms.com/forums/index.php/topic,5344.msg41096.html#msg41096
get_file_contents
function get_file_contents($filename)
Returns the contents of file name passed
From http://www.nutt.net/2006/07/08/file_get_contents-function-for-php-4/#more-210
Generated by Natural Docs
3 of 3
Purpose
The Filter class contains all functions relating to filtering, theremoving of documents from the result set
Summary
Filter Class The Filter class contains allfunctions relating to filtering,the removing of documentsfrom the result set
Functions
execute Filter documents via either a customfilter or basic filter
basicFilter Do basic comparison filtering
execute
function execute($resource,$filter )
Filter documents via either a custom filter or basic filter
basicFilter
function basicFilter ($value)
Do basic comparison filtering
Generated by Natural Docs
Welcome
Snippet
Snippet
Wordpress Config
Template Class
Filter Class
ATOM
JSON
XML
Summary
Tagging
Search
1 of 1
Purpose
The Debug class contains all functions relating to Ditto’simplimentation of the MODx debug console
Summary
Debug Class The Debug class contains allfunctions relating to Ditto’simplimentation of the MODxdebug console
Functions
render_link Render the links to the debugconsole
render_popup Render the contents of the debugconsole
preparePrefetch Create the content of the Prefetchtab
prepareFilters Create the content of the Filterstab
prepareDocumentInfo Create the output for theDocument Info tab
prepareBasicInfo Create the outut for the Info ta
prepareTemplates Create the output for theTemplates tab
render_link
function render_link($dittoID,$ditto_base)
Render the links to the debug console
render_popup
Welcome
Snippet
Snippet
Wordpress Config
Template Class
Debug Class
ATOM
JSON
XML
Summary
Tagging
1 of 3
function render_popup($ditto,$ditto_base,$ditto_version,$ditto_params,$IDs,$fields,$summarize,$templates,$orderBy,$start,$stop,$total,$filter,$resource )
Render the contents of the debug console
preparePrefetch
function preparePrefetch($prefetch)
Create the content of the Prefetch tab
prepareFilters
function prepareFilters($filter)
Create the content of the Filters tab
prepareDocumentInfo
function prepareDocumentInfo($resource)
Create the output for the Document Info tab
prepareBasicInfo
function prepareBasicInfo($ditto,$ditto_version,
2 of 3
$IDs,$summarize,$orderBy,$start,$stop,$total )
Create the outut for the Info ta
prepareTemplates
function prepareTemplates($templates)
Create the output for the Templates tab
Generated by Natural Docs
3 of 3
Purpose
A class designed to help developers impliment a debugconsole like to the one in Ditto 2
Summary
MODx DebugConsole
A class designed to helpdevelopers impliment a debugconsole like to the one in Ditto2
Functions
render Render the contents of the debugconsole
save Save the debug console as a file
makelink Render the links to the debug console
buildURL Build a URL with regard to a prefix
makeTab Render a tab
makeMODxSafe Make all MODx tags safe for theoutput
makeParamTable Turn an array of parameters in theformat [“param”] => “value” into atable
cleanArray Remove empty items from the array
array2table Translate a result array into a HTMLtable
render
function render($cTabs,$title,$base_path)
Render the contents of the debug console
Welcome
Snippet
Snippet
Wordpress Config
Template Class
MODx Debug Console
ATOM
JSON
XML
Summary
Tagging
1 of 3
save
function save($html,$filename)
Save the debug console as a file
makelink
Render the links to the debug console
buildURL
function buildURL($args, $id = false,$prefix = "" )
Build a URL with regard to a prefix
makeTab
function makeTab($title,$content)
Render a tab
makeMODxSafe
function makeMODxSafe($value)
Make all MODx tags safe for the output
makeParamTable
2 of 3
function makeParamTable($parameters = array(),$header = "",$sort = true,$prep = true,$wordwrap = true )
Turn an array of parameters in the format [“param”] =>“value” into a table
cleanArray
function cleanArray($array)
Remove empty items from the array
array2table
function array2table($array, $recursive = false,$return = false,$null = ' ')
Translate a result array into a HTML table
Author: Aidan Lister [email protected]
Version: 1.3.1
Link: http://aidanlister.com/repos/v/function.array2table.php
Generated by Natural Docs
3 of 3
ATOM
Purpose
Collection of parameters, functions, and classes that expandDitto’s output capabilities to include ATOM
Summary
ATOM Collection of parameters,functions, and classes thatexpand Ditto’s outputcapabilities to include ATOM
Parameters
abbrLanguage Language for the Atom feed
charset Charset to use for the Atom feed
abbrLanguage
Purpose
Language for the Atom feed
Options
Any valid 2 character language abbreviation
Default
[LANG]
Related
language
charset
Purpose
Charset to use for the Atom feed
Options
Welcome
Snippet
Template Class
ATOM
JSON
XML
Summary
Tagging
Compatibility
1 of 2
Any valid charset identifier
Default
MODx default charset
Generated by Natural Docs
2 of 2
JSON
Purpose
Collection of parameters, functions, and classes that expandDitto’s output capabilities to include JSON
Summary
JSON Collection of parameters,functions, and classes thatexpand Ditto’s outputcapabilities to include JSON
Parameters
abbrLanguage Language for the JSON document
copyright Copyright message to embed in theJSON document
ttl Time to live for the JSON feed
abbrLanguage
Purpose
Language for the JSON document
Options
Any valid 2 character language abbreviation
Default
[LANG]
Related
language
copyright
Purpose
Copyright message to embed in the JSON document
Welcome
Snippet
Template Class
ATOM
JSON
XML
Summary
Tagging
Compatibility
1 of 2
Options
Any text
Default
[LANG]
ttl
Purpose
Time to live for the JSON feed
Options
Any integer greater than 1
Default
120
Generated by Natural Docs
2 of 2
Purpose
Collection of parameters, functions, and classes that expandDitto’s output capabilities to include RSS
Summary
RSS Collection of parameters,functions, and classes thatexpand Ditto’s outputcapabilities to include RSS
Parameters
copyright Copyright message to embed in theRSS feed
abbrLanguage Language for the RSS feed
ttl Time to live for the RSS feed
charset Charset to use for the RSS feed
xsl XSL Stylesheet to format the RSSfeed with
copyright
Purpose
Copyright message to embed in the RSS feed
Options
Any text
Default
[LANG]
abbrLanguage
Purpose
Welcome
Snippet
Template Class
ATOM
JSON
RSS
XML
Summary
Tagging
Compatibility
1 of 3
Language for the RSS feed
Options
Any valid 2 character language abbreviation
Default
[LANG]
Related
language
ttl
Purpose
Time to live for the RSS feed
Options
Any integer greater than 1
Default
120
charset
Purpose
Charset to use for the RSS feed
Options
Any valid charset identifier
Default
MODx default charset
xsl
Purpose
XSL Stylesheet to format the RSS feed with
Options
2 of 3
The path to any valid XSL Stylesheet
Default
None
Generated by Natural Docs
3 of 3
XML
Purpose
Collection of parameters, functions, and classes that expandDitto’s output capabilities to include XML
Summary
XML Collection of parameters,functions, and classes thatexpand Ditto’s outputcapabilities to include XML
Parameters
copyright Copyright message to embed in theXML feed
abbrLanguage Language for the XML feed
ttl Time to live for the RSS feed
charset Charset to use for the RSS feed
xsl XSL Stylesheet to format the XMLfeed with
copyright
Purpose
Copyright message to embed in the XML feed
Options
Any text
Default
[LANG]
abbrLanguage
Purpose
Welcome
Snippet
Template Class
ATOM
JSON
XML
Summary
Tagging
Compatibility
1 of 3
Language for the XML feed
Options
Any valid 2 character language abbreviation
Default
[LANG]
Related
language
ttl
Purpose
Time to live for the RSS feed
Options
Any integer greater than 1
Default
120
charset
Purpose
Charset to use for the RSS feed
Options
Any valid charset identifier
Default
MODx default charset
xsl
Purpose
XSL Stylesheet to format the XML feed with
Options
2 of 3
The path to any valid XSL Stylesheet
Default
None
Generated by Natural Docs
3 of 3
Purpose
Filtering companion to Reflect or other date based filtering
Summary
Date Filter Filtering companion to Reflector other date based filtering
Parameters
dateFilterSource Source for the day, month, and yearto filter by
dateSource Source of the [+date+] placeholder
dateFilterDefault Determine the default filter
month Month to filter by
year Year to filter by
day Day to filter by
Placeholders
year Year being filtered by
month Month being filtered by
month Numeric version of the month beingfiltered by
day Day being filtered by
dateFilterSource
Purpose
Source for the day, month, and year to filter by
Options
get gets the value of year, month, andday from the URL (pre-appended withthe Ditto ID)
params gets the value from the snippet cal
text name of the request variable to use
Default
Welcome
Snippet
ATOM
JSON
XML
Date Filter
Summary
Tagging
Compatibility
Italian
1 of 4
get
dateSource
Purpose
Source of the [+date+] placeholder
Options
# Any UNIX timestamp from MODx fields orTVs such as createdon, pub_date, oreditedon
Default
”createdon”
Related
dateFormat
dateFilterDefault
Purpose
Determine the default filter
Options
0 filter off
1 current year
2 current year and month
3 current year, month, and day
Default
0
month
Purpose
Month to filter by
Options
# Number between 1-12 (inclusive) that
2 of 4
corresponds to the month to filter by
Default
[NULL]
year
Purpose
Year to filter by
Options
# Any numerical year (4 numbers; ex: 2006)
Default
[NULL]
day
Purpose
Day to filter by
Options
# Any numerical day within the currentmonth
Default
[NULL]
year
Content
Year being filtered by
month
3 of 4
Content
Month being filtered by
month
Content
Numeric version of the month being filtered by
day
Content
Day being filtered by
Generated by Natural Docs
4 of 4
Purpose
Example file for basing new Extenders on
Summary
Example Example file for basingnew Extenders on
Parameters Define any parametersneeded in the extender orto override Ditto defaults
param The purpose of yourparameter goes here
Placeholders Defin the values ofcustom placeholders foraccess in the tpl like so[+phname+]
$placeholders[‘example’] Add the placeholder exampleto the custom placeholders listwith the source pagetitle inboth display and backendusing the exampleFunctioncallback and pagetitle as thefield for QuickEdit.
exampleFunction Takes the resource array foran individual document andreturns the value of theplaceholder, in this case theuppercase version of thepagetitle
Filters Define custom or basicfilters within the extenderto expand Ditto’s filteringcapabilities
$filters[“custom”][“exampleFilter”]
Add the filter exampleFilter tothe custom filters list with thesource pagetitle and thecallback exampleFilter
exampleFilter Takes the resource array foran individual document andasks for the return of a 0 or 1with 1 removing the documentand 0 leaving it in the resultset.
$filters[“parsed”][] Add the pre-parsed filter tothe parsed filters list with thesource as id, the value of
Welcome
Snippet
ATOM
JSON
XML
Example
Summary
Tagging
Compatibility
Italian
1 of 3
9239423942 and the mode 2
Define any parameters needed in the extender or tooverride Ditto defaults
param
Purpose
The purpose of your parameter goes here
Options
Any options that your parameter can have go here
Default
”default”
Defin the values of custom placeholders for access in thetpl like so [+phname+]
$placeholders[‘example’]
Add the placeholder example to the custom placeholderslist with the source pagetitle in both display and backendusing the exampleFunction callback and pagetitle as the fieldfor QuickEdit. If you only needed the placeholder in thefrontent you would just use “pagetitle” as the first value ofthe array. If the callback was in a class use thearray($initialized_class,”member”) method.
2 of 3
exampleFunction
function exampleFunction($resource)
Takes the resource array for an individual document andreturns the value of the placeholder, in this case theuppercase version of the pagetitle
Define custom or basic filters within the extender toexpand Ditto’s filtering capabilities
$filters[“custom”][“exampleFilter”]
Add the filter exampleFilter to the custom filters list withthe source pagetitle and the callback exampleFilter
exampleFilter
function exampleFilter($resource)
Takes the resource array for an individual document andasks for the return of a 0 or 1 with 1 removing the documentand 0 leaving it in the result set. In this case, if the lowercase value of the pagetitle is foo, it is removed while allother documents are shown
$filters[“parsed”][]
Add the pre-parsed filter to the parsed filters list with thesource as id, the value of 9239423942 and the mode 2
Generated by Natural Docs
3 of 3
Purpose
Adds support for changing Ditto parameters via URL
Note
All variables must be prefixed with ditto_ for the snippet to recognize them!If a Ditto id is set use the sntax
Summary
Request Adds support for changing Ditto parameters via URL
Parameters
stripTags Remove HTML tags from the parameters provided
bad Parameters that are not allowed to be set
good Parameters that are allowed to be set
dbg Output variables being set
stripTags
Purpose
Remove HTML tags from the parameters provided
Options
0 off
1 on
Default
1 on
bad
Purpose
Parameters that are not allowed to be set
Options
Any valid Ditto options separated by commas
Default
”seeThroughtUnpub,showInMenuOnly,showPublishedOnly,debug,start,config,extenders,dittoID”
good
Purpose
Parameters that are allowed to be set
Welcome
Snippet
ATOM
JSON
XML
Request
Summary
Tagging
Compatibility
Italian
1 of 2
Options
Any valid Ditto options separated by commas
Default
All parameters execpt those in &bad
dbg
Purpose
Output variables being set
Options
0 off
1 on
Default
0 off
Generated by Natural Docs
2 of 2
Purpose
Legacy support for the [+summary+] placeholder
Summary
Summary Legacy support for the[+summary+] placeholder
Parameters
trunc Enable truncation on the summaryplaceholder
truncAt Location to split the content at
truncLen Number of characters to show of thecontent
truncOffset Number of charactars to “wander”either way of truncLen
truncText Text to be displayed in [+link+]
tplTrunc Template to be used for [+link+]
trunc
Purpose
Enable truncation on the summary placeholder
Options
0 off
1 on
Default
1 on
truncAt
Purpose
Location to split the content at
Welcome
Snippet
ATOM
JSON
XML
Summary
Tagging
Compatibility
Italian
1 of 3
Options
Any unique text or code string that is contained in thecontent of each document
Default
”<!-- splitter -->”
truncLen
Purpose
Number of characters to show of the content
Options
Any number greater than truncOffset
Default
300
truncOffset
Purpose
Number of charactars to “wander” either way of truncLen
Options
Any number greater less than truncLen
Default
30
truncText
Purpose
Text to be displayed in [+link+]
Options
Any valid text or html
Default
2 of 3
”Read more...”
tplTrunc
Purpose
Template to be used for [+link+]
Options
Any valid chunk nameCode via @CODE:File via @FILE:
Placeholders
[+url+] URL of the document
[+text+] &truncText
Default
&truncText
Generated by Natural Docs
3 of 3
Tagging
Purpose
Collection of parameters, functions, and classes that expandDitto’s functionality to include tagging
Summary
Tagging Collection of parameters,functions, and classes thatexpand Ditto’s functionality toinclude tagging
Parameters
tagDocumentID ID for tag links to point to
tagData Field to get the tags from
caseSensitive Determine whether or not tagmatching and duplicate tag removalare case sensitive
tagMode Filtering method to remove tags
tagDelimiter Delimiter that splits each tag in thetagData source
tagDisplayDelimiter What separates the tags in[+tagLinks+]
tagSort Sort the tags alphanumerically
tagDisplayMode How to display the tags in[+tagLinks+]
tags Allow the user to provide initial tagsto be filtered
tplTagLinks Define a custom template for thetagLinks placeholder
tagCallback Allow the user to modify both wherethe tags come from and how theyare parsed.
Placeholders
tagLinks Nice ‘n beautiful tag list with linkspointing to tagDocumentID
tags Raw tags separated by tagDelimiter
tagDocumentID
Welcome
Snippet
ATOM
JSON
XML
Summary
Tagging
Compatibility
Italian
1 of 6
Purpose
ID for tag links to point to
Options
Any MODx document with a Ditto call setup to receivethe tags
Default
Current MODx Document
tagData
Purpose
Field to get the tags from
Options
Comma separated list of MODx fields or TVs
Default
[NULL]
caseSensitive
Purpose
Determine whether or not tag matching and duplicate tagremoval are case sensitive
Options
0 off
1 on
Default
0 off
tagMode
Purpose
Filtering method to remove tags
2 of 6
Options
onlyAllTags show documents that have allof the tags
onlyTags show documents that haveany of the tags
removeAllTags remove documents that haveall of the tags
removeTags documents that have any ofthe tags
Default
”onlyTags”
tagDelimiter
Purpose
Delimiter that splits each tag in the tagData source
Options
Any character not included in the tags themselves
Default
” “ space
tagDisplayDelimiter
Purpose
What separates the tags in [+tagLinks+]
Options
Any character
Default
&tagDelimiter
tagSort
Purpose
Sort the tags alphanumerically
3 of 6
Options
0 off
1 on
Default
1 on
tagDisplayMode
Purpose
How to display the tags in [+tagLinks+]
Options
1 string of links &tagDisplayDelimiterseparated
2 ul/li list
Note
Output of individual items can be customized bytplTagLinks
Default
1 string of links &tagDisplayDelimiterseparated
tags
Purpose
Allow the user to provide initial tags to be filtered
Options
Any valid tags separated by tagDelimiter
Default
[NULL]
tplTagLinks
Purpose
Define a custom template for the tagLinks placeholder
4 of 6
Options
Any valid chunk nameCode via @CODEFile via @FILE
Default
<a href="[+url+]" class="ditto_tag" rel="tag">[+tag+]</a>
tagCallback
Purpose
Allow the user to modify both where the tags come fromand how they are parsed.
Options
Any valid function name
Default
[NULL]
Notes
The function should expect to receive the following threeparameters: tagData - the provided source of the tagsresource - the resource array for the document being parsedarray - return the results in an array if true
tagLinks
Content
Nice ‘n beautiful tag list with links pointing totagDocumentID
tags
Content
Raw tags separated by tagDelimiter
5 of 6
Generated by Natural Docs
6 of 6
Purpose
Default templates for Reflect
Summary
DefaultTemplates
Default templates for Reflect
Variables
$defaultTemplates Holds the default templates
Variables
$defaultTemplates
$defaultTemplates
Holds the default templates
Generated by Natural Docs
Welcome
Snippet
Snippet
Default Templates
Wordpress Config
Template Class
ATOM
JSON
XML
Summary
Tagging
Search
1 of 1
Description
Generates date based archives using Ditto
Author
Mark Kaplan for MODx CMF
Version
2.1.0
Note
If Reflect is not retrieving its own documents, make sure thatthe Ditto call feeding it has all of the fields in it that you planon calling in your Reflect template. Furthermore, Reflect willONLY show what is currently in the Ditto result set. Thus, ifpagination is on it will ONLY show that page’s items.
Summary
Reflect Snippet Generates date based archivesusing Ditto
Parameters
ditto_base Location of Ditto files
config Load a custom configuration
id Unique ID for this Ditto instance forconnection with other scripts (likeReflect) and unique URL parameters
getDocuments Force Reflect to get documents
showItems Show individual items in the archive
groupByYears Group the archive by years
targetID ID for archive links to point to
dateSource Date source to display for archiveitems
dateFormat Format the [+date+] placeholder inhuman readable form
yearSortDir Direction to sort documents
monthSortDir Direction to sort the months
start Number of documents to skip in theresults
phx Use PHx formatting
Welcome
Snippet
Snippet
Wordpress Config
Template Class
ATOM
JSON
XML
Summary
Tagging
1 of 9
params Pass parameters to the Ditto instanceused to retreive the documents
source Name of the Ditto snippet to use
tplContainer Container template for the archive
tplYear Template for the year item
tplYearInner Template for the year item (the ul tohold the year template)
tplMonth Template for the month item
tplMonthInner Template for the month item (the ulto hold the month template)
tplItem Template for the individual item
ditto_base
Purpose
Location of Ditto files
Options
Any valid folder location containing the Ditto source codewith a trailing slash
Default
[(base_path)]assets/snippets/ditto/
config
Purpose
Load a custom configuration
Options
”default” default blank config file
CONFIG_NAME Other configs installed in theconfigs folder or in any folderwithin the MODx base path via@FILE
Default
”default”
Related
2 of 9
extenders
id
Purpose
Unique ID for this Ditto instance for connection withother scripts (like Reflect) and unique URL parameters
Options
Any valid folder location containing the Ditto source codewith a trailing slash
Default
”” blank
getDocuments
Purpose
Force Reflect to get documents
Options
0 off
1 on
Default
0 off
showItems
Purpose
Show individual items in the archive
Options
0 off
1 on
Default
1 on
3 of 9
groupByYears
Purpose
Group the archive by years
Options
0 off
1 on
Default
1 on
targetID
Purpose
ID for archive links to point to
Options
Any MODx document with a Ditto call setup withextenders=`dateFilter`
Default
Current MODx Document
dateSource
Purpose
Date source to display for archive items
Options
# Any UNIX timestamp from MODx fields orTVs such as createdon, pub_date, oreditedon
Default
”createdon”
Related
dateFormat
4 of 9
dateFormat
Purpose
Format the [+date+] placeholder in human readableform
Options
Any PHP valid strftime option
Default
”%d-%b-%y %H:%M”
Related
dateSource
yearSortDir
Purpose
Direction to sort documents
Options
ASC ascending
DESC descending
Default
”DESC”
Related
monthSortDir
monthSortDir
Purpose
Direction to sort the months
Options
ASC ascending
DESC descending
Default
”ASC”
5 of 9
Related
yearSortDir
start
Purpose
Number of documents to skip in the results
Options
Any number
Default
0
phx
Purpose
Use PHx formatting
Options
0 off
1 on
Default
1 on
params
Purpose
Pass parameters to the Ditto instance used to retreivethe documents
Options
Any valid ditto parameters in the format name:valuewith multiple parameters separated by a pipe (|)
Note
This parameter is only needed for config, start, and phxas you can now simply use the parameter as if Reflect wasDitto
6 of 9
Default
[NULL]
source
Purpose
Name of the Ditto snippet to use
Options
Any valid snippet name
Default
”Ditto”
tplContainer
Purpose
Container template for the archive
Options
Any valid chunk nameCode via @CODE:File via @FILE:
Default
See default.tempates.php
7 of 9
tplYear
Purpose
Template for the year item
Options
Any valid chunk nameCode via @CODE:File via @FILE:
Default
See default.tempates.php
tplYearInner
Purpose
Template for the year item (the ul to hold the yeartemplate)
Options
Any valid chunk nameCode via @CODE:File via @FILE:
Default
See default.tempates.php
tplMonth
Purpose
Template for the month item
Options
Any valid chunk nameCode via @CODE:File via @FILE:
Default
See default.tempates.php
8 of 9
tplMonthInner
Purpose
Template for the month item (the ul to hold the monthtemplate)
Options
Any valid chunk nameCode via @CODE:File via @FILE:
Default
See default.tempates.php
tplItem
Purpose
Template for the individual item
Options
Any valid chunk nameCode via @CODE:File via @FILE:
Default
See default.tempates.php
Generated by Natural Docs
9 of 9
Template Class
Purpose
The Template class contains all functions relating to Ditto’shandling of templates and any supporting functions theyneed
Summary
Template Class The Template class contains allfunctions relating to Ditto’shandling of templates and anysupporting functions they need
Functions
template Set the class language and fieldsvariables
process Take the templates and parse themfor tempalte variables, Check tomake sure they have fields, and sortthe fields
findTemplateVars Find al the template variables in thetemplate
sortFields Sort the array of fields provided bytype
replace Replcae placeholders with theirvalues
determine Determine the correct template toapply
fetch Get a template, based on version byDoze
get_file_contents Returns the contents of file namepassed
template
function template()
Set the class language and fields variables
Welcome
Snippet
Snippet
Wordpress Config
Template Class
ATOM
JSON
XML
Summary
Tagging
1 of 3
process
function process($template)
Take the templates and parse them for tempaltevariables, Check to make sure they have fields, and sort thefields
findTemplateVars
function findTemplateVars($tpl)
Find al the template variables in the template
sortFields
function sortFields ($fieldList)
Sort the array of fields provided by type
replace
function replace($placeholders,$tpl )
Replcae placeholders with their values
2 of 3
determine
function determine($templates,$x,$start,$stop,$id )
Determine the correct template to apply
fetch
function fetch($tpl)
Get a template, based on version by Doze
http://modxcms.com/forums/index.php/topic,5344.msg41096.html#msg41096
get_file_contents
function get_file_contents($filename)
Returns the contents of file name passed
From http://www.nutt.net/2006/07/08/file_get_contents-function-for-php-4/#more-210
Generated by Natural Docs
3 of 3