You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tracking the modal state can be a pain. There are many situations where we need to modify urls, append &modal=1 to not lose the modal state.
I just found another situation of that today. And while working on a fix I had an idea how we could improve the situation in a more generic way (see idea at the end).
Short description of the issue
I want to show a pagelist in a modal to manage my tags that are then used in a page reference field.
To open the pagelist in a modal I added this button to my page select field:
Rather than fighting all urls on the backend, hooking here and there and whatnot, what if we used the approach that I took here not only for the pagelist but all across the admin?
What if we didn't care about url rewriting on the backend at all and modified the urls only via javascript? This could happen on page load, and on ajaxComplete, and when calling ProcessWire.addModalParams() (for example).
I think that should improve the situation, because if anybody built a module for whatever feature, he/she didn't even have to think about also supporting modals with custom PHP code like this:
He/she would just output a link like /foo/bar/whatever and the modal link watcher would kick in on page load and transform it into /foo/bar/whatever?modal=1 if in a modal and if not, leave it as is.
The text was updated successfully, but these errors were encountered:
Tracking the modal state can be a pain. There are many situations where we need to modify urls, append &modal=1 to not lose the modal state.
I just found another situation of that today. And while working on a fix I had an idea how we could improve the situation in a more generic way (see idea at the end).
Short description of the issue
I want to show a pagelist in a modal to manage my tags that are then used in a page reference field.
To open the pagelist in a modal I added this button to my page select field:
This opens the pagelist as expected:
But when I click on "edit" on one of those pages the modal state gets lost:
Expected behavior
The page edit button should open the page editor in a modal like this:
Optional: Suggestion for a possible fix
I have just added a solution to the RockAdminTweaks module: https://github.com/baumrock/RockAdminTweaks/blob/main/tweaks/PageList/AddModalParam/AddModalParam.js
Idea
Rather than fighting all urls on the backend, hooking here and there and whatnot, what if we used the approach that I took here not only for the pagelist but all across the admin?
What if we didn't care about url rewriting on the backend at all and modified the urls only via javascript? This could happen on page load, and on ajaxComplete, and when calling ProcessWire.addModalParams() (for example).
I think that should improve the situation, because if anybody built a module for whatever feature, he/she didn't even have to think about also supporting modals with custom PHP code like this:
He/she would just output a link like
/foo/bar/whatever
and the modal link watcher would kick in on page load and transform it into/foo/bar/whatever?modal=1
if in a modal and if not, leave it as is.The text was updated successfully, but these errors were encountered: