Hello,
For a site, the client needs two different visualization for each instance of her “project” page.
One which is the public, navigable, page, and another one which is for her private use and that works as a portfolio-like page of each “project” instance.
The difference between these two types of visualizations of “project” are so dissimilar they can’t really share a template, they would use two different templates.
And since the ammount of “project” pages is dynamic, I can’t hardcode this manually, it has to be dynamic.
My question is how to best approach this.
My first thought was to perhaps to use a page model to overwrite the children() method so each “project” has a virtual page child, which is a copy of itself except for the template. The url for this virtual child would be the original url with “portfolio” added to the end of it, or something similar.
Something like:
models/project.php
<?php
class PortfolioProjectPage extends Kirby\Cms\Page
{
public function children()
{
$portfolioPage = [
'slug' => $this . 'portfolio',
'num' => $this->num(),
'template' => 'portfolio-page',
'model' => 'portfolio-page',
// ...
'content' => [
'title' => $this->title() . ' ( Portfolio )',
// ...
];
return Pages::factory($portfolioPage, $this);
}
}
But this seems like, perhaps, an overcomplicated solution. I tend to forget about simple solutions.
Is there any simple solution I am missing here.
Thank you!