[SOLVED] Reload document when adding content childnodes. Possible?


(Peter Rauber) #1

Hello guys,

While working on a customer project I am creating a document nodeType which should be rendered differnetly depending on the number of childnodes (of a specific childnode-path).

Rendering works already as I can hand over the number of children to the rendering fusion objects.

But the editor-experience is not perfect right now because after adding the second content-childnode there is no page reload triggered which would solve that problem.

I already found this discussion Force page reload on Page Tree rearrangement and also looked into http://neos.readthedocs.io/en/stable/ExtendingNeos/InteractionWithTheNeosBackend.html#javascript-events
I guess the javascript events mentioned in the manual are not fired anymore. I tried

if (typeof document.addEventListener === 'function') {
  document.addEventListener('Neos.NodeCreated ', function(event) {
          console.log(event);
  }, false);
}

But nothing happens when I add a content node.

Any ideas on who to tackle this?

Kind regards,
Peter


(Aske Ertmann) #2

Hi Peter,

Which version of Neos are you using? Because the new React UI does not trigger those events to my knowledge, only the old UI does that.

However it should be possible to hook into the new UI, however it would require quite a lot more code and know how to do currently. Maybe someone more familiar with the inner workings of the new UI can help /cc @dimaip @sebastian

Best,
Aske


(Dmitri Pisarev) #3

Wow, yes, there are so many ways to achieve this in the new UI, but all of them a bit low-level. We are thinking of more high-level API, but that would take some time.

E.g. you could register your own server feedback handler:

serverFeedbackHandlers.set('Neos.Neos.Ui:NodeCreated/YourCustomHandler', (feedbackPayload, {store}) => {
        if (someCheck) {
            // do something
        }
    });

[SOLVED] Javascript events (i.e. Neos.PageLoaded) for the react UI
(Peter Rauber) #4

Thanks for the quick response. I try out your feedback. Thank you. Will post my outcome here, will happen next week.


(Peter Rauber) #5

Nice update: I had a nice slack call with @dimaip today and we see 3 possible solutions for my need:

  1. Add a custom feedbackHandler (JS-Code that is loaded in the host-frame of the backend)
  2. Wait for a solution for https://github.com/neos/neos-ui/issues/754 and listen to the events in the guest-frame
  3. Implementing a new yaml-configuration for content-collections same as the existing “reloadIfChanged” for properties

@dimaip will implement a mixture between 1 and 3 for me (please correct me if I am wrong about that). This will happen next week.


(Peter Rauber) #6

We got a result: https://packagist.org/packages/internezzo/childreload
Thanks to @dimaip for the coding under the flag of internezzo. :slight_smile: