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

pdoResources

Snippet to display a list of resources. It is an advanced replacement for getResources: it has all the features but without flaws .

Knows how to properly sort the TV settings , attach a table with the sample , include or exclude categories from different contexts , and much more .

Properties

Resource selection properties

These properties determine what resources will appear in the generated list.

NameDefaultDescription
&parentsCurrent resourceComma-separated list of parents, to find results . Set to 0 for unlimited, to +0 for the top level . If a parent id starts with a dash, it and its children are excluded from the query.
&depth10Search depth of child resources from parent in the Resource Tree.
&resourcesComma-separated list of resources to add to the results. If the id of the resource starts with a hyphen , this resource is excluded from the query.
&contextLimit the resources from the given context.
&whereAn array of additional selection parameters encoded JSON.
&showHidden1Show resources that are hidden in the menu.
&showUnpublished0Show unpublished resources.
&showDeleted0Show resources that have been marked as deleted.
&hideContainers0Exclude container resources, that is, resources with «isfolder = 1».
&select0A comma-separated list of fields to retrieve. You can specify a JSON string array, for example {"modResource":"id,pagetitle,content"}.
&sortbypagetitleAny resource field for sorting, including TVs if the &includeTVs property is also set. You can specify a JSON string with an array of multiple fields, for example {"tvname":"ASC", "pagetitle":"DESC"}. To randomly sort use «RAND()».
&sortdirDESCSort direction : Ascending or Descending.
&limit10Limit the number of results . You can use «0» for no limit.
&offset0Number of items to skip, from the beginning.
&first1Number of the first item of the output results.
&lastAutomatic, by the formula (total + first - 1)Number of the last item of the results.
&loadModelsComma-separated list of components whose model you need to download for building a query. Example: &loadModels=`ms2gallery,msearch2`.
&tvFiltersList of filters on TV , delimited AND and OR. Separator specified parameter &tvFiltersOrDelimiter represents the logical OR condition thereon and conditions grouped primarily. Within each group, you can specify a list of values, separated &tvFiltersAndDelimiter. Search values ​​can be performed in any particular TV, if it is provided «myTV == value», or in any «value». Sample call: &tvFilters=`filter2==one,filter1==bar%||filter1==foo`. Please note: The filter uses the LIKE operator and the "%" symbol is a metacharacter. This will search for the values for the resources that are located in the site_tmplvar_contentvalues table, not from the default settings of the TV.
&tvFiltersAndDelimiter,Separator for conditional AND property &tvFilters.
&tvFiltersOrDelimiter||Separator for conditional OR property &tvFilters.

Template Properties

These properties specify the chunks that contain the templates to format the generated output.

NameDescription
&returnIdsSet to "1" to return a string with a list of resource ids, instead of complete results. All of the templates are ignored.
&tplName chunk for formatting the individual items. If not specified, the contents of the resource fields will be printed to the screen.
&tplFirstName of the chunk to format the first item in the results.
&tplLastName of the chunk to format the last item in the results.
&tplOddName of the chunk to format every odd-numbered item in the results.
&tplWrapperChunk - wrapper, to wrap all results. Accepts one placeholder:[[+output]]. It does not work in conjunction with &toSeparatePlaceholders.
&wrapIfEmptyIncludes outer chunk wrapper &tplWrapper* even if there are no results.
&tplConditionDefines a field of the resource to evaluate against keys defined in the &conditionalTpls property.
&tplOperatorOptional operator for comparison of the resource field &tplCondition with an array of values and in &conditionalTpls chunks.
&conditionalTplsA JSON object defining a map of field values and the associated tpl Chunks to use when the field defined by &tplCondition matches the value. The comparison operator is specified in &tplOperator. For operators such as isempty you can not use an array of keys.
&outputSeparatorOptional string to separate the results.

Result Properties

These properties further define what data to fetch and how to display it.

NameDefaultDescription
&fastMode0Quick mode for processing chunks. All raw tags (output modifiers, snippets, etc.) are removed.
&idxThe starting number of iterations of the output.
&setTotal0Indicates if the total placeholder should be populated with a count of the results.
&totalVartotalName of the placeholder for storing the total number of results.
&includeContent0Indicates if the «content» field of each resource should be returned in the results.
&includeTVsComma-separated list of Template Variable values that should be included in the placeholders available to each resource template . Example: «action,time» will produce the placeholders [[+tv.action]] and [[+tv.time]].
&prepareTVs1, prepares all TVs specified in &includeTVsComma-separated list of media source-dependant TV values to be prepared before output.
&processTVsComma-separated list of TVs that should be processed according to their output options. If set to «1», all TV listed in &includeTVs will be processed.
&tvPrefixtv.Prefix TV property.
&scheme-1Type of URL scheme, passed to modX::makeUrl(). See this for a list of valid options.
&useWeblinkUrl0Generate link to the weblink resource, not to the destination URL. NOTE: To get this properly working, be sure to use [[+link]] instead of [[~[[+id]]]] eg. <a href="[[+link]]">[[+pagetitle]]</a>.
&toPlaceholderSave output to a placeholder with this name instead of displaying the output to the screen.
&toSeparatePlaceholdersEach item will be displayed in a placeholder with a name starting with this value and ending with the sequential number starting from zero. For example, by specifying the property value «myPl», you'll get placeholders [[+myPl0]], [[+myPl1]] & etc.
&showLog0Show additional debugging information on the processing of the snippet only to logged-in Manager users.

Examples

A simple list of the children of resource #1:

modx
[[pdoResources?
  &parents=`1`
  &depth=`0`
  &tpl=`ListRowTpl`
]]

To add a TV named «image», then the call will be as follows:

modx
[[pdoResources?
  &parents=`1`
  &depth=`0`
  &tpl=`ListRowTpl`
  &includeTVs=`image`
]]

The chunk ListRowTpl will now allow the placeholder [[+tv.image]].