Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support relative paths in getLevelListing #3110

Open
w00fz opened this issue Dec 21, 2020 · 2 comments
Open

Support relative paths in getLevelListing #3110

w00fz opened this issue Dec 21, 2020 · 2 comments
Assignees

Comments

@w00fz
Copy link
Member

w00fz commented Dec 21, 2020

Currently getLevelListing only supports absolute paths.

A bad 500 error happens when trying to load a relative path:

error: {type: "Error", message: "Maximum function nesting level of '256' reached, aborting!", code: 0,…}
code: 0
file: "/Users/djamil/Projects/grav/grav-core/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php"
line: 340
message: "Maximum function nesting level of '256' reached, aborting!"
type: "Error"

Firs this error should be more graceful. But also there is nothing stopping us from supporting relative paths. The ajax call for the page picker already sends all the required information. Assuming we are editing /admin/my/page and we are trying to load the route ../other-page in the Page-Picker, this is how it goes:

POST /admin/my/page

data:
__form-name__: flex-pages
form-nonce: <nonce>
__unique_form_id__: <unique_id>
route: ../other-page
field: route
action: getLevelListing
admin-nonce: <admin_nonce>
initial: true
@mahagr mahagr transferred this issue from getgrav/grav-plugin-admin Dec 23, 2020
@mahagr mahagr assigned w00fz and unassigned rhukster Dec 23, 2020
@mahagr
Copy link
Member

mahagr commented Dec 23, 2020

@w00fz
Relative paths work now, except that the selected item is not highlighted because of ../other-page does not match anything. I added a new json variable called route, which contains the normalized version of the selected route.

@mahagr
Copy link
Member

mahagr commented Dec 23, 2020

We may also want to add support for returning all-relative paths? Or even to select if you want to use relative or absolute path in the modal...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants