Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

PHP: searchForTemplate

Bruno Meilick edited this page Mar 15, 2020 · 3 revisions

This plugin provides a Site- and a Page-Method to search for all sub-pages/sub-files/structures with a given template. This will only find objects that have an autoid field in their Blueprint.

Page Template

// SLOW (with lot of pages) because of index
$allEventPages = site()->index()->filterBy('template', 'event');

// faster with autoid
$eventPagesCollection = site()->searchForTemplate('event');

// or starting from a different root
$eventPagesCollection = page('hawaii/music')->searchForTemplate('event');

File Template

$eventFilesCollection = page('hawaii/music')->searchForTemplate('eventfile');

Structure Object

// use hardcoded string 'structureobject'
$eventStructureObjectsCollection = page('hawaii/music')->searchForTemplate('structureobject');
Clone this wiki locally