-
-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Unexpected issue with sorting on setting the num prop when creating pages in code. #6443
Comments
Figured out where the difference occurs - line 281 in the PageActions trait. When setting the num prop directly the logic says that it doesn't need sorting. Lines 280 to 283 in c1e6ff7
|
I have not an idea about the fixing the issue but as workaround you can use |
@afbora yes, setting num to 0 does work but I just needed some example code to highlight the issue. Something needs fixing somewhere, but not sure if it is code or documentation. There is an inconsistency in using num in the props vs setting it after creation with changeStatus, and I think changeStatus after creation is probably the more understandable way, but num is documented as a prop and the difference in the behaviour is not obvious. |
Seems that setting |
I ran into the same issue today trying to create a number of pages sorted by publishing date. I feel the |
@philipmarnef when you are saying "the same issue", you mean the draft vs. num competition, right? Not the passing num directly as prop vs. calling the method afterwards? @SeriousKen I think the consideration here is that passing |
@distantnative I tried setting both |
Description
The following two pieces of code do not produce the same results:
Expected behavior
I would expect both pieces of code to create a series of pages, inserting each page with sort number of 1 so the pages should be in the reverse order they were created.
The first one works, the second prefixes all pages with 1. Which is odd, because the last thing the create method does is call
changeStatus('listed', $props['num'])
before returning the page object.I presume that setting
num
on the array is doing something internally that is causing an issue when calling thechangeStatus
method before returning the object.Screenshots
To reproduce
Your setup
Kirby Version
Kirby 4.2.0
Console output
Your system (please complete the following information)
Linux Ubuntu 20.04 LTS running on WSL2 on Windows 11 Dell laptop
Additional context
The text was updated successfully, but these errors were encountered: