Skip to content
  1. Extras
  2. pdoTools
  3. Snippets
  4. pdoArchive

pdoArchive

Snippet outputs site document archive grouped by year, month and day.

Chunks

  • tpl - Name chunk for displaying resource. If not set, resource fields will be printed to screen.
modx
@INLINE <li>[[+date]] <a href="[[+link]]">[[+menutitle]]</a></li>
  • tplYear - Chunk for year output
modx
@INLINE <h3>[[+year]] <sup>([[+count]])</sup></h3><ul>[[+wrapper]]</ul>
  • tplMonth - Chunk for month output
modx
@INLINE <li><h4>[[+month_name]] <sup>([[+count]])</sup></h4><ul>[[+wrapper]]</ul></li>
  • tplDay - Chunk for day output
modx
@INLINE <li><h5>[[+day]] <sup>([[+count]])</sup></h5><ul>[[+wrapper]]</ul></li>
  • tplWrapper - Wrapper chunk for all results. Accepts one placeholder: [[+output]].

To hide year, month or day output, pass empty strings for those chunks.

Parameters

Snippet accepts general pdoTools parameters.

ParameterDefaultDescription
tplWrapperWrapper chunk for all results. Accepts one placeholder: [[+output]].
wrapIfEmptyEnables wrapper chunk output (tplWrapper) even when no results.
dateFieldcreatedonResource field for date: createdon, publishedon or editedon.
dateFormat%H:%MDate format for strftime()()
showLogShow extra snippet debug info. Only for users logged in to the context "mgr".
sortbycreatedonAny resource field for sort, including TV if listed in "includeTVs". JSON for multiple fields. Use "RAND()" for random.
sortbyTVSort by TV param. If not in &includeTVs, it is added automatically.
sortbyTVTypeTV sort type: string, integer, decimal or datetime. If empty, TV is sorted by its type.
sortdirDESCSort direction: descending or ascending.
sortdirTVASCTV sort direction: descending or ascending. If not set, equals parameter &sortdir.
limitMax number of results. You can use "0".
offsetNumber of results to skip.
depth10Depth of child resources from the parent.
outputSeparator\nOptional string to separate results.
toPlaceholderIf set, the snippet stores all data in a placeholder with this name instead of outputting.
parentsComma-separated list of parent IDs for the search. By default the search is limited to the current parent. Use 0 for no limit. If a parent ID starts with minus, it and its children are excluded.
includeContentInclude "content" field.
includeTVsList of TVs to include, via comma. For example: "action,time" yields placeholders [[+action]] and [[+time]].
prepareTVs1TVs to prepare before output. Default "1" = all TVs from &includeTVs.
processTVsTVs to process before output. "1" = all from &includeTVs. Empty by default.
tvPrefixtv.Prefix for TV placeholders.
whereJSON-encoded array of extra conditions.
showUnpublishedInclude unpublished resources.
showDeletedInclude deleted resources.
showHidden1Include resources hidden from menu.
hideContainersExclude containers (resources with isfolder = 1).
contextLimit results by resource context.
totalVartotalPlaceholder name for total result count.
resourcesComma-separated list of resource IDs to include. Prefix with minus to exclude from results.
selectComma-separated list of fields to select. JSON array allowed, e.g. {"modResource":"id,pagetitle,content"}.
schemeLink scheme: "uri" for fast uri substitution or param for modX::makeUrl().
useWeblinkUrl1Generate link based on resource class.

Examples

Basic call:

modx
[[!pdoArchive?
  &parents=`0`
]]

Via pdoPage:

modx
[[!pdoPage?
  &element=`pdoArchive`
  &parents=`0`
]]

[[!+page.nav]]

Ticket output example (as in page header image):

modx
[[!pdoPage?
  &element=`pdoArchive`
  &parents=`0`
  &limit=`1000`
  &maxLimit=`1000`
  &scheme=`uri`
  &sortby=`publishedon`
  &dateField=`publishedon`
  &where=`{"class_key":"Ticket"}`
  &tplYear=``
  &tplMonth=`@INLINE <h4>{$month_name} {$year} <sup>({$count})</sup></h4><ul>{$wrapper}</ul>`
  &tpl=`@INLINE <li>{$date} <a href="{$link}">{$menutitle}</a> / <small>{$section}</small></li>`
  &leftJoin=`{
    "Parent": {
      "class": "modResource"
    }
  }`
  &select=`{
    "modResource": "*",
    "Parent":"Parent.pagetitle as section"
  }`
]]