Blog Sections Open

Building Previous and Next Navigation with DocLister

When a section is already rendered by DocLister, it makes sense for previous and next links to follow the exact same dataset and order. The original solution behind this topic did exactly that by letting DocLister return

When a section is already rendered by DocLister, it makes sense for previous and next links to follow the exact same dataset and order. The original solution behind this topic did exactly that by letting DocLister return a machine-readable list first.

Base Listing

[[DocLister? &parents=`[*id*]` &depth=`5` &showParent=`0`]]

Navigation Helper

$ID = $modx->documentIdentifier;
$params = array_merge($modx->event->params, array(
    'api' => 'id,pagetitle',
    'debug' => '0'
));
$json = $modx->runSnippet('DocLister', $params);
$data = jsonHelper::jsonDecode($json, array('assoc' => true));

From there, the helper locates the current document inside the returned array and builds links to the previous and next items.

Why This Pattern Works

  • navigation follows the same source list as the archive
  • ordering stays consistent with menuindex or other DocLister parameters
  • you do not have to duplicate selection logic in a second snippet

If a page belongs to a listing, the navigation should ideally be derived from that same listing. DocLister makes that possible when used as both a renderer and a structured data source.

Newer post

Using shk_widget radioimage Output Inside Ditto Templates

How to make Shopkeeper radioimage parameters render correctly when product cards are built through Ditto placeholders instead of direct TV tags.

Older post

Understanding Checkbox TV Value Formats in Evolution CMS

A quick guide to how checkbox TVs store values and why frontend output often looks odd until the stored format is understood.