When a page is created it is invisible. When I make it visible, a sort dialog is created. Is it possible for the page to be made visible and sorted last by default without opening the dialog?
thanks
When a page is created it is invisible. When I make it visible, a sort dialog is created. Is it possible for the page to be made visible and sorted last by default without opening the dialog?
thanks
No, there is no option for that.
Options:
/panel/app/forms/pages/toggle.php
)panel.page.update
hook and optionally hide the status toggle in the sidebar. So when a user checks the publish option (and updates the page), the hook is triggered and the page sorted. (Keep in mind that if you hide the status toggle you wonāt be able to sort pages manually anymore)In some installations of kirby the dialog that appears is just an OK for making the page visible. May it be related to the sorting options of subpages?
Also, just to get it clear, is there any way to prevent sorting of subpages at all ?
Thank you
Yes; if you sort by date or title (or any other field), it doesnāt make sense to have a dialog to select a sorting number.
You mean, prevent making pages visible?
”Ja! no, just preventing manual sorting.
After some time fiddling with this, I understand it better. Although Iād say that num/sort/visibility combinations may be a bit confusing for newcomers like me.
In example you can do
num: zero
sort: flip
ā¦but not
num: zero
sort: desc
Sorting sorts, but numbering names and sorts. Also you can:
num: date
sort: flip
ā¦and
sort: date asc/desc
Not saying it does not make sense, but imho the functionalities of num and sort overlap in a manner that can be confusing.
Again in my subjective oppinion Iād expect naming/numbering to just name and sorting to sort.
Thank you very much.
No, sorting and visibility are closely related. With default sorting enabled, I donāt think there is a way to prevent manual sorting of pages, Iām afraid.
You could disable the visibility toggle completely and use a field to determine sort order, for example using the AutoID plugin or a simple hook. Then in your template, instead of using the folder sort order for sorting, use this field (you can also then use this field to sort by in the Panel).
Related question.
The Autopublish plugin uses a simple hook to sort a newly created page ālastā in a manner similar to this:
kirby()->hook('panel.page.create', function($page) {
if ( $page->intendedTemplate == 'exhibitor-item' ):
$page->sort('last');
endif;
});
This code , as a hook under config, does not seem to work for me.
I was wondering if maybe the culprit could be the (ālastā) bit, which I cannot find anywhere in docs or forum.
Can you actually do? :
$page->sort('last');
Thank you.
I think so, at least the AutoID plugin works. Thereās a pair of parens missing in your code after intendedTemplate
, though.
aw⦠that was it, sorry
But⦠is ālastā documented anywhere? I tried and could not find, certainly not under $page->sort() where it says the value needs to be numeric.
Thank you
The last
parameter is not documented because the sort function here is called in a Panel context; you canāt use these special keywords (last, first) in a template/controller etc. (see /panel/app/src/panel/models/page/sorter.php
). Or if you do, you end up with a literal ālastā as the sorting number.