I write a plugin which generates a login profile page the same way as the login plugin does. But it should work with a modular page.
It registers the page using the same code
$route = $this->config->get('plugins.login.route_profile');
$pages = $this->grav['pages'];
$page = new Page();
// $page->init(new \SplFileInfo(__DIR__ . '/pages/profile.md'));
$page->init(new \SplFileInfo(__DIR__ . '/pages/modular.md'));
$page->slug(basename($route));
$pages->addPage($page, $route);
// Profile page may not have the correct Cache-Control header set,
// force no-store for the proxies.
$page->expires(0);
If it is a normal page, it works perfect. If it is a modular page, it does not render the modular subpages. The same page (including subpages) renders, when I save it as a normal page (like 04.profile).
It looks like
content:
items: '@self.modular'
does not find the modular pages. My Twig template using page.collection() does not evaluate to an array, the {% for … loop does not render the loop body.
How do I register the modular subpages?
Is there a way to do that in the frontmatter as fully named items?
Do I have to do it programmatically in my plugin?
Is there any example code?
Thanks,
Birger