<p>Yahtzee.</p>
<pre><code>use craft\web\View;
use yii\base\Event;

...

Event::on(View::class, View::EVENT_AFTER_RENDER_PAGE_TEMPLATE, function (Event $event) {
    // do things
});
</code></pre>
<p><a href="https://docs.craftcms.com/api/v3/craft-web-view.html#event-after-render-page-template" rel="nofollow noreferrer">https://docs.craftcms.com/api/v3/craft-web-view.html#event-after-render-page-template</a></p>

CC BY-SA 4.0
2022-09-23T18:12:09.173Z
2022-09-23T18:12:09.173Z
plaintxt
<p>I'm working on a Content Security Policy and need to set an HTTP header after all templates have finished processing. Right now I'm doing that by calling a module variable at the bottom of the main layout template, but that feels brittle.</p>
<p>Is there an Event that can be used for this? I've looked through craft\events in the <a href="https://docs.craftcms.com/api/v3/" rel="nofollow noreferrer">API docs</a> but don't see a good candidate.</p>

CC BY-SA 4.0
2022-09-23T16:28:11.650Z
Ah! Maybe EVENT_AFTER_RENDER_PAGE_TEMPLATE? Does "page template" equate to the layout that's being extended?
plaintxt
<craft3><events>
Is there an Event that detects when all templates have been processed?
# Is there an Event that detects when all templates have been processed?

(Asked by: username_0 on 2022-09-23)

I'm working on a Content Security Policy and need to set an HTTP header after all templates have finished processing. Right now I'm doing that by calling a module variable at the bottom of the main layout template, but that feels brittle.

Is there an Event that can be used for this? I've looked through craft\events in the [API docs](https://docs.craftcms.com/api/v3/) but don't see a good candidate.

**Tags:** craft3, events

> **Comments:**
> **username_0**: Ah! Maybe EVENT_AFTER_RENDER_PAGE_TEMPLATE? Does "page template" equate to the layout that's being extended?  

---

## 1 answers

### Answer by username_0 on 2022-09-23. Score: 1

Yahtzee.
use craft\web\View;
use yii\base\Event;

...

Event::on(View::class, View::EVENT_AFTER_RENDER_PAGE_TEMPLATE, function (Event $event) {
    // do things
});

https://docs.craftcms.com/api/v3/craft-web-view.html#event-after-render-page-template


---

