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

pdoNeighbors

The snippet pdoNeighbors displays the previous and the next resources.

It can display several neighbors at once, check their status (unpublished, published), and allows you to specify sorting.

You can display the previous / next resources based on «menuindex», publication date or other resource field.

Options

Accepts all options of pdoTools (except chunks templates) and some of its own:

ParameterDefaultDescription
&idThe current documentThe resource ID, of which are displayed the neighbors.
&tplPrevsee belowChunk reference to the previous document.
&tplUpsee belowChunk reference to the parent document.
&tplNextsee belowChunk reference to the following document.
&tplWrappersee belowChunk-wrapper for wrapping results. Uses placeholders: [[+left]], [[+top]], [[+right]] and [[+log]]. It does not work in conjunction with &toSeparatePlaceholders.
&toPlaceholderIf not empty, the snippet will save all data to the placeholder specified, instead of displaying the output with the snippet call.
&showLog0Display log information of the snippet. Only authorized in the context «mgr».
&loop10/1: Hide/show neighbours first/last entry if at the end of list

Template Chunks

TemplateDefault
&tplPrev@INLINE <span class="link-prev"><a href="/[[+uri]]">&larr; [[+menutitle]]</a></span>
&tplUp@INLINE <span class="link-up">&uarr; <a href="/[[+uri]]">[[+menutitle]]</a></span>
&tplNext@INLINE <span class="link-next"><a href="/[[+uri]]">[[+menutitle]] &rarr;</a></span>
&tplWrapper@INLINE <div class="neighbors">[[+prev]][[+up]][[+next]]</div>

Examples

Default snippet displays the neighbors as they are in the resource tree, that is, based on «menuindex»:

modx
[[pdoNeighbors]]

By default, the neighbors are selected from the current document, but you can specify a different id:

modx
[[pdoNeighbors?
  &id=`55`
]]

The snippet is perfect for displaying links to adjacent news items (it is best to sort by date of publication):

modx
[[pdoNeighbors?
  &sortby=`publishedon`
  &sortdir=`asc`
]]