Blog Sections Open

Showing Parent Resource Titles in AjaxSearch Results

Search results become much easier to scan when they show section context, not only the found page title.

The original note asked how to use getParent inside result.tpl.html so AjaxSearch results could display the parent page title along with the hit itself.

Example idea

$id = $modx->documentObject['id'];
$parent = $modx->getParent($id);
echo $parent['pagetitle'];

Why this is useful

When a site has many similarly titled pages, parent context helps the user understand where the result lives: section, category, or content branch.

Implementation caution

The result template should not become a dumping ground for expensive logic. If parent lookups are needed for many results, it is usually cleaner to prepare that data in the result-building layer or in a dedicated helper instead of scattering logic through the output template.

Newer post

Paginating EvoGallery Output and Opening Images with Fancybox

How to combine EvoGallery pagination with a lightbox flow such as Fancybox when one gallery page should show only a limited number of thumbnails at a time.

Older post

Preparing Checkbox TV Data for autoFilter

How to structure checkbox TV values so autoFilter can work with them predictably instead of receiving loosely formatted label strings.