ProcessWire.config.page should return correct id of edited page
Right now if you are editing a page in the admin the ProcessWire.config object reads
"page": {
"id": 10,
"name": "edit",
"process": "ProcessPageEdit"
}
regardless on which page you are really on.
But one might need the actual id of the page you are editing (for taking actions with JavaScript), which is in my case "processwire/page/edit/?id=564030".
I know that the page has a class that looks like this "ProcessPageEdit-id-564030" but it is cumbersome to get the id from this class.
I would suggest, that the ProcessWire.config.page object returns the ID and also name of the actual page you are editing:
"page": {
"id": 564030,
"name": "name-of-the-page",
"process": "ProcessPageEdit"
}
If this was implemented like described, it would result in a couple of issues:
- It would break any existing code relying on the id/name properties referring to the actual page we're currently on — i.e. the edit page.
- It would be an unexpected deviation from how these values work everywhere else in the admin.
As such, it does not seem like a good idea — but that being said, if ProcessPageEdit was to populate a separate object of its own within the ProcessWire object, that could indeed be a very nice addition. This object could potentially also include additional values, such as the template id and/or name for the page being edited.
@jmartsch What Teppo says is correct here. But if you need the edited page ID from JS in PW's page editor, here's the way I usually get it:
var id = $('#Inputfield_id').val();
After reading the comments here, I would like to request adding an additional property like
pageEditId which in my case would have the value 564030 (as described in the initial issue)
An additional pageEditTemplate property with the name of the real template would be nice.
This is backward compatible and would not break stuff, but gives us devs more flexibility.