Extenders

"Extenders" are PHP code files that add functionality to Ditto. They can define additional parameters that can be included in the Ditto snippet call, additional filters, and additional placeholders that can be used in Ditto's template. The extenders that come pre-packaged with Ditto 2 are:

  • Summary - Adds support for the legacy placeholder
  • Request - Adds support for changing Ditto parameters via URLs
  • Tagging - Add support for tagging
  • DateFilter - Allows you to filter the list of documents by the year, month, and date of the field used as the source of the placeholder
  • Example - A commented, skeleton extender for developers

Installation

Extender files are named with this pattern:

name.extender.inc.php

They should be installed this directory:

/assets/snippets/ditto/extenders/

However, you can place them in another directory and append @FILE to the name of the extender when calling like so:

&extenders=`@FILE:foo/extender.php`

@FILE paths are relative from the MODx base path

The standard set of extenders that ship with Ditto 2 have the filenames:

dateFilter.extender.inc.php request.extender.inc.php summary.extender.inc.php tagging.extender.inc.php example.extender.inc.php

Usage

By default all extenders are inactive. To make one or more extenders active, you must use the &extenders parameter in your Ditto call. The value of this parameter must be a comma-separated list of the extenders you wish to use in that call. The example below will call the summary and dateFilter default extenders as well as the extender.php file located in the foo folder.

&extenders=`summary,dateFilter,@FILE foo/extender.php`

Extenders can define their own parameters, filters, and placeholders. So once an extender has been activated you can add its parameters to the Ditto call and its placeholders to your Ditto template.

Based on documentation work by Bill Fernandez