This is a user-contributed Extra. If you find issues or would like more info or help, please contact the author.

A simple example without pagination

Select the latest 20 documents from the parent with ID=5.


The text of each document will be have extra processing by the summary extender, with preliminary removal of HTML tags and length curtailed to 200 +/-50 characters. The placeholders tv.img amd tv.tag will be available in the chunk, containing the values of the template variables img and tag.

A look at the ListSummaryPost chunk:

<div class="post">
  <div class="date">[+createdon+]</div>
  <h3><a href="/[~[+id+]~]">[+pagetitle+]</a></h3>
  <div class="tag"><span>Tags: </span> [+tv.tag+]</div>
  <div class="content"><a href="/[~[+id+]~]" title="[+pagetitle+]"><img src="[+tv.img+]" alt=""></a>
    <a href="/[~[+id+]~]" title="Details">More details</a>

Using configs

[!DocLister? &config=`test`!]

Following this we create the JSON file test.json in the snippet subfolder /config/custom/ with the following content:

    "display" : "20",
    "summary" : "notags,len",
    "dateSource" : "pub_date",
    "parents" : "5",
    "tvList" : "img,tag",
    "id" : "lastnews",
    "tpl" : "ListSummaryPost"

This call will have an identical result to the previous example.

Using lexicons

[!DocLister? &tpl=`example` &customLang=`news`!]

Following this, we create the PHP file news.php containing a $_lang array in the snippet's /lang/ folder.

<?php if (!defined('MODX_BASE_PATH')) { die('What are you doing? Get out of here!');}
$_lang = array();
$_lang['newsTitle'] = 'Latest news';
return $_lang;

The chunk example can now use the tag [%newsTitle%], which will be automatically replaced by the message "Latest news".

Advanced example with pagination

&dateFormat=`%d.%m.%Y в %H:%M` 
&addWhereList=`c.template IN (6,7)` 
&TplPage=`@CODE: <li><a href="[+link+]">[+num+]</a></li>` 
&TplCurrentPage=`@CODE: <li class="active"><a href="[+link+]">[+num+]</a></li>` 
&TplWrapPaginate=`@CODE: <div class="pagination"><ul>[+wrap+]</ul></div>`


In this example all documents from the container with ID=2, to a depth of 2 and based on templates 6 or 7, are selected. Container documents will then be filtered out (the documents within which the search was carried out. That is, document with ID=2 and all its children that are containers).

Upon output, "page" pagination will be applied and the templates for paginated items will be redefined as those named in the TplWrapPaginate, TplCurrentPage and TplPage parameters. The "next" and "previous" link templates will be empty (hence no text will be output for them).

The prefix list will be added to all the DocLister placeholders, and the values of the template variables img and tag will be added to every document that is output in the placeholders tv.img and tv.tag respectively. Template variable img will be rendered in accordance with the widget set when it was created.

A total of four documents will be displayed per page. Sorting will be not by creation date, but by menuindex (position in the menu). The document's publication date will be used as the date source.

Here is the ListSummaryPost chunk

<div class="post">
  <div class="date">[+createdon+]</div>
  <h3><a href="/[~[+id+]~]">[+pagetitle+]</a></h3>
  <div class="tag"><span>Tags:</span> [+tv.tag+]</div>
  <div class="content"><a href="/[~[+id+]~]" title="[+pagetitle+]">[+tv.img+]</a>
    <a href="/[~[+id+]~]" title="Details">More details</a>

Example of output from a table other than site_content

The snippet chunk:
<div class="row"><div class="span12">
 <h3 class="pagination-centered">[+name+]</h3>

In this example the information will be output from the site_snippets table. The id field acts as the PrimaryKey column. Sorting is in ascending order of the name column.

Suggest an edit to this page.