it might sound confusing but the result is quite simple:
Is it possible to add the current page automatically to the related one when the related one is added to the current pages field.
The goal ist to add the connection between the pages by only adding the relation once instead of “from both sides”.
No, it won’t be. If you want it to be visible in the Panel, you would have to use a page.update:after hook and actually store the information in the other page.
To be honest, I don’t really think this is the best way to go about this. If a page A is related to page B, that automatically means that page B is also related to Page A and IMO it is not necessary to store this information in both pages.
Thanks @texnixe, it works! But you’re right: if I can’t remove the connection the same way (which is impossible, i guess) it would be better to simply display the connection inside the template and store the information in only one page, right?
My initial thought was to keep the overwiew over the connections in the panel, but i think it’s more important to have the right information in the frontend.
I didn’t mean to say it is not possible, it’s just a lot of stuff to handle to keep things up to date and I really wonder what happens if hooks update potentially many pages while they are at the same time edited by someone. So maybe hook updates fail in this case, but I cannot really answer this question.
To achieve removal of removed connections you would have to do mainly the same as in the above snippet, just the other way round:
compare oldpage state with newpage state to find out what has been removed