Hello!
I have made a static function to retrieve some attribute from all the children from a page path, and also another one filtering all pages by type. None work. Neither count($pages) or foreach() through the collection seems to work.
Anyone can point me to what I'm doing wrong or what ca be happening??
The functions:
public static function getPageTitle($collection_options, $path)
{
$grav = Grav::instance();
$l = $grav['log'];
$l->info('Tutorial');
$page = $grav['page'];
$collection = $page->evaluate([$collection_options => $path]);
$titles = [];
foreach ($collection as $item) {
$titles[$item->title()] = $item->title();
}
$l->info('Count: '.count($collection));
$l->critical(print_r($titles, true));
return $titles;
}
This is called from a blueprint with :
fields:
content:
fields:
llocs:
type: select
label: Municipis
data-options@: ['\Grav\Theme\Espurnes::getPageTitle', '@page.modular', '/qui-som/territori-barroc']