Draft preview isn't working with custom routes and page url model

Hi, first of all, thank you for your amazing work on this CMS, I absolutely love working with it !
However, I currently have an issue previewing drafts with my custom routes.

This issue has already been raised here : Draft Preview giving error page and here : Issue with route and draft page preview so I tried to adapt my routes to make it work but I can’t seem to figure why it doesn’t…

This is the routes I am using :
‘pattern’ => ‘(:any)’,
‘action’ => function($uid) {

            $page = page($uid);

            if(!$page) $page = page('realisations/' . $uid);
            if(!$page) $page = page('ressources/' . $uid);
            if(!$page) $this->next();

            return site()->visit($page);	
		'pattern' => ['realisations/(:any)', 'ressources/(:any)'],
		'action'  => function($uid) {
			return go($uid);

and the custom page model :

    class RealisationPage extends Page {
        public function url($options = null): string {
        return $this->site()->url() . '/' . $this->slug();

I also tried with different variations in the preview blueprint and the whole thing only work if I remove the routes and set the preview to this :

  preview: "{{ site.url }}/{{ page.parent.slug }}/{{ page.slug }}"

At this point, I don’t know if I just made a typo mistake somewhere or if I am doing something completely wrong.

If anyone can help, it would be greatly appreciated, thank you in advance.

Hi Rachl,

just kind of a bump.

I have the exact same problem.
Tried to use the ideas from the other posts, but I can’t get the draft preview working with custom routes.

1 Like

Hi Sebli,

Glad I’m not the only one having this issue, I ended up telling the client tu change the status tu “unlisted” because it works that way and I wasn’t able to resolve it myself… I hope a solution can be found eventually :thinking:

same :slight_smile: