I try to understand how in the Kirby demo the preview URL for Agency Clients redirect to the homepage.
I managed to do it myself with the preview option in the blueprint.
Parent page: preview: "/{{ site.homepage }}#{{ page.slug }}".
Subpage: preview: "/{{ site.homepage }}#{{ page.parent.slug }}".
Thanks! I hadn’t thought about template redirection here.
I think the best way is to use both, template redirection and preview in blueprint, so the URL on the “preview” button in the panel is the good one (with the preview blueprint option), and the original URL stay inaccessible (with template redirection).
Do you have an idea about my second question about the preview depending on the status ?
I actually think the best way is a template redirection and a custom page model overwriting the url() method:
// site/models/agency-client.php
<?php
class AgencyClientPage extends Page {
public function url($options = null): string {
return $this->parent()->url() . '#' . $this->slug();
}
}
The ->url() method is not only used for the preview button in the panel. You don’t have to change any code in the frontend, either. Think of menus, search results, …
Concerning your second question: I don’t think that’s possible.