I've tried a lot of ways, but without success
For example
use Grav\Common\Page\Pages;
public function onPagesInitialized()
{
$pages = $this->grav['pages'];
print_r($pages->get('/about'));
// or
print_r($pages->find('/about', true));
}
returns nothing
The plugin of flex objects is enabled
EDITED
Adding the function onPluginsInitialized() with enabling onPagesInitialized() also doesn't help:
public function onPluginsInitialized(): void
{
$this->enable([
'onPagesInitialized' => ['onPagesInitialized', 0],
]);
}
The following is a sample of how one can get a specific page object.
When using the following folder structure: (from Blog skeleton)
Assuming event 'onPagesInitialized' has been subscribed to, the following code correctly returns the sought pages:
Note: When the request is made by plugin Admin, pages will not be initialized. One needs to call
$this->grav['admin']->enablePages();first.