SimpleSearch Results

I have SimpleSearch working but wanted to know if there’s a way to include the name of the parent directory next to the page title of each result.

For example:

Search Results

  1. Consulting (parent) Services (links to page).
  2. Therapy (parent) Services (links to page).

I looked through the SS docs but didn’t see anything pertaining to that specific feature. I’m thinking it would look similar to a breadcrumb. I considered using pdoCrumbs but couldn’t figure out how to combine it with the SimpleSearch results.

Here’s the SS Chunk that displays each row of results:

<li>
    <h2>
        <a href="[[+link:is=``:then=`[[~[[+id]]]]`:else=`[[+link]]`]]">[[+pagetitle]]</a>
    </h2>
    <p>[[+introtext:ellipsis=`300`]]</p>
</li>

Maybe use FastFields or pdoTools Extra. Than you can do something like this:

[[#[[#[[+id]].parent]].pagetitle]]
[[pdoField?
    &id=`[[+id]]`
    &field=`pagetitle`
    &top=`2`
]]

You already get the placeholder [[+parent]] for the parent ID. So this (inner) query is unnecessary.

You still have to make an additional query for the title though. → [[#[[+parent]].pagetitle]]

(On MODX 3, use the pdoTools extra to get the fastField syntax working.)

2 Likes