Hi all, is it possible to show the status of a page in a Pages Field like it is shown in a Pages Section?
I mean that nice colored circle… i did not find a good solution, but
info: "{{ page.slug }} - {{ page.status }}"
Tnx!
Yes, you can do that with a custom page method that returns the html for such an icon depending on page status, see the source code if you want to use exactly the same markup.
and call that method via the info property?
`` ìnfo: “{{ page.customStatus }}”```
Exactly.
I made it a bit easier, but that works for me.
At the moment, the only thing i needed, was to show the state, listed or not.
Works great with page-methods. tnx again: @pixelijn
<?php
Kirby::plugin('myname/page-methods', [
'pageMethods' => [
'getStateForPagesField' => function () {
$color = '#d16464';
if($this->status() === 'listed') {
$color = '#a7bd68';
}
$markup = '<p style="color:'.$color.';">'.$this->slug().'</p>';
return $markup;
}
]
]);
info: "{{ page.getStateForPagesField }}"
1 Like
Since K3.6/K3.7 to query and output markup, we need to change the following line:
info: "{< page.getStateForPagesField >}"