Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions simplesearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,10 @@ public function onPagesInitialized()
continue;
}

if ($cpage->modular()) {
$this->collection->remove($cpage);
$parent = $cpage->parent();
$parent = $this->getModularParent($cpage, $cpage);
if ($parent)
$extras[$parent->path()] = ['slug' => $parent->slug()];
}


}
}
}
Expand Down Expand Up @@ -212,7 +210,25 @@ public function onPagesInitialized()
}
}


/**
* Test if there is modular in page parents and get modular page
*
* @param Page $cpage Page object to perform test if it is modular
* @param Page $leafPage Original page
*
* @return Page Modular page parent or null
*/
protected function getModularParent($cpage, $leafPage) {
$parent = null;
if ($cpage->modular()) {
$this->collection->remove($leafPage);
$parent = $cpage->parent();
} elseif ($cpage->parent()) {
$parent = $this->getModularParent($cpage->parent(), $cpage);
}
return $parent;
}

/**
* Set needed variables to display the search results.
*/
Expand Down