Render site in the update after hook

But back to the main problem: I tried following things. Both of them are not deliver the right solution. This two examples comes into my hook. The main thing is to get the new content of the homepage in the site.update:after hook.

  1. Update the Homepage:
$homepage = site()->homepage();
$homepage->update();
  1. Injecting $newPage to the Homepage:
$homepage = site()->homepage();
$homepage->setSite($newSite);

Still got the values of the previous version.

Btw. The result you can check with:


dump($homepage->site());

As you see. The output there is not what is changing right on update.

I don’t think there is any point in pursuing this approach any further, as it just doesn’t work. Maybe you can post the code in your home controller and template (and the corresponding class you are using there), so that we might find a better way to deal with that.

Having said that, you could trigger a page.update.after hook from your site hook, passing on the data you need via the named arguments or a session variable.

But in general, I’m not convinced that this approach of rendering a page to create a file is a good one.

What about simply reloading the page?

You can’t reload from a hook. And the TO wants to send additional data to the page render method.

Good point. Let’s make an example:

  1. The editor say: This element is not red, it’s blue
  2. During the next reloading, we collecting this information.
  3. We generate a css file with this information
  4. On next page call, the new css is created and the element is blue.

So, in this case, the user needs to reload the page twice to see the difference.
My example in the 5. Posts works fine. But not on site update.

I reconstruct everything. And now it works somehow. :tada:

Sorry for bothering you guys with this. But if only someone can use some of this workflow, I have already achieved my goal here.

Here is the plugin based on this topic. Feel free to play with it! :hugs:

Still remains a mystery to me, why you don’t call your Stylewriter class right from the hooks.

My class collecting stylings from the rendered pages. With the end of the rendering process, my Stylewirter class ran across the jordan and i don’t have access to the collected styles anymore. And therefore: Nothing to write in the hook

I need to write the stylings right before the end of my template. This i do with the
<?php $sw->seal() ?>
statement. How else could i output the data? I rather avoid to touch the php buffers, just to escape a json with my information.

Make sense? Do i interpreted your Question right?

Yes, ok, I understand what you are doing there. IMO, this seems to produce a lot of overhead every time the page is rendered. But as you say, it’s experimental.

Thats True. Therefore i’m passing the sw_render bool, that prevent the converting and writing stuff only from the hook. Otherwise we having the cache…
I don’t want to extend this topic artifically. But is it true, that the page is no longer cacheable when a variable in the site controller is set?