I was wondering if there is a way to validate the preview token yourself? I use subpages as blocks and want to show the draft blocks when you are previewing from the panel. At this moment I loop through the listed ones so I would like to loop through listed and drafts and if the preview token is there AND if I would be able to check that it’s valid I could show the draft blocks too.
That’s indeed a way to do it. Haven’t thought of that yet. Downside is that if you are logged in the site you will always see those blocks and not only when you are going via the preview.
To clarify my question, yes, the token is per page and I have a parent page wich includes subpages as “blocks”. So if the token of the parent would check out I could include the draft children also.
The problem is how do you know you are going via the preview? Because unless the page is a draft, there is no token or special url, unless you specifically define one.
Yes, but only then. I thought you wanted to preview the parent page.
You can check if the current URL is the preview URL of the block and show a block based on that, but then this would only be true for that particular block, not all draft blocks.
If you actually want to see all draft blocks, you could create a special preview url for the parent page (maybe with a query string preview and then check if the current url contains that query and if it the same as the previewUrl().