I’m attempting to use Kirby’s “unlisted” status as a type of poor-man’s “redirected” status (since I’m only using “public” and “draft” previously and Kirby doesn’t yet allow custom statuses, this seems like the cleanest option).
The last piece of the puzzle is updating the UI on page status change.
The PHP code is almost the default changeStatus
code, except that it adds a custom text field for the redirect URL. The value from this field gets saved to the content entry. Here’s the submit
code:
'submit' => function (string $id) {
$request = App::instance()->request();
$page = Find::page($id);
$updatedPage = $page->changeStatus($request->get('status'), $request->get('position'));
$archivedRedirectUrl = $request->get('archived_redirect_url');
if ($archivedRedirectUrl) {
$updatedPage->update([
'archived_redirect_url' => $archivedRedirectUrl,
]);
}
return [
'event' => 'page.changeStatus',
];
},
On the Vue side, I conditionally display a notice that the page is redirected if the content entries has the archived_redirect_url
field and it has a value. When the user is on an entry page and updates the redirect URL, this display should update (it displays the redirect URL). The only approach I’ve been able to think of for this is to add a Vue watcher:
this.$store.watch(
() => this.$store.getters['content/values'](),
(updatedContentObject) => {
if (archivedRedirectUrl !== updatedContentObject.archivedRedirectUrl) {
this.archivedRedirectUrl = updatedContentObject.archivedRedirectUrl
}
}
)
But this doesn’t work (the function is never executed).
Any ideas?
What is the proper/working approach to this?