First post, so be gentle!
I want to create a select (dropdown) in admin with a list of pages which have the specific template ‘parish’, i.e. with the pagename ‘parish.md
’.
I have created a theme (incubator) and in and in incubator.php
I have a function which I want to return the array of page slugs/titles which I can use in @data-options for the select ('@data-options': '\Grav\Theme\Incubator::getParishes'
)
I am missing something - I know the function below is all wrong but how do I achieve what I want?
public static function getParishes()
{
$collection = new Collection();
$collection = $collection->ofType('parish')->order('date', 'desc');
//dump($collection);
$titles = [];
foreach ($collection as $page) {
$titles[$page->slug()] = $page->title();
}
return $titles;
}
$collection
appears to just contain everything. That said I don’t even know how to iterate through $collection
!
Thanks
Nick