No sort dialog when making page visible?

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:

  • modify the core (/panel/app/forms/pages/toggle.php)
  • use a publish checkbox/toggle together with a 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)
1 Like

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).

1 Like

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.

1 Like

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.

1 Like