ideas icon indicating copy to clipboard operation
ideas copied to clipboard

Enable or disable preview depending of the page status

Open yoanmalie opened this issue 5 years ago • 2 comments

My suggestion is to have the possibility to enable or disable the preview depending of the page status. As a simple example who come in my mind at the moment: On the Kirby Demo, for the Agency Clients we can preview the clients list on the homepage, it should be nice if we can choose to not preview it if the client is on Archived or Upcomig status (draft and unlisted).

yoanmalie avatar May 13 '20 13:05 yoanmalie

I just tried to use a page method to achieve this. Because we can use the query language I expected this to work when returning false. It doesn't.

<?php
Kirby::plugin('my/methods', [
	'pageMethods' => [
		'anchorPreview' => function () {
			if($this->isDraft()) {
				return false;
			}
			else {
				return $this->parent()->url() . '#' . $this->slug();
			}
		}
	]
]);
title: Project Page
options:
  preview: "{{ page.anchorPreview }}"

Adding support for a (false) boolean might be an easy solution for this.

medienbaecker avatar May 13 '20 21:05 medienbaecker

Moved to https://kirby.nolt.io/35

yoanmalie avatar Sep 17 '20 12:09 yoanmalie