# Adding template hooks in core rather than overriding templates in plugin

**URL:** <https://talk.getindico.io/t/adding-template-hooks-in-core-rather-than-overriding-templates-in-plugin/1676>\
**Category:** Development\
**Created:** [February 13, 2020, 11:09am UTC](https://talk.getindico.io/t/adding-template-hooks-in-core-rather-than-overriding-templates-in-plugin/1676 "2020-02-13T11:09:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![omegak](https://talk.getindico.io/user_avatar/talk.getindico.io/omegak/32/452_2.png) [@omegak](https://talk.getindico.io/u/omegak)\
**Post date:** [February 13, 2020, 11:09am UTC](https://talk.getindico.io/t/adding-template-hooks-in-core-rather-than-overriding-templates-in-plugin/1676/1 "2020-02-13T11:09:33Z")

</div>

I would like to know what is your position regarding adding `template_hook`s in indico-core templates whenever possible, rather than overriding templates. The rationale for this is to prevent divergencies between plugin-overridden templates and core templates as they evolve over time.

I’m anticipating that much of the maintenance efforts of the plugin will end up being directed at keeping plugin-overridden templates up-to-date with the changes introduced in their corresponding core templates. For that reason, I believe a saner approach would be to avoid overriding templates **as much as possible**. Whenever the plugin needs to _add_ stuff, we would try to do so via `template_hook`.

The drawback with this approach is that we would need coordination with indico-core maintainers for every `template_hook` we want to add, which may slow us down significantly in the short term. At the same time, having more `template_hook`s introduce no penalty and it makes Indico more easily extensible for all plugin developers, so maybe we can go ahead without double checking with you before hand for every single `template_hook` we need.

An ideal strategy for us would be:

- Whenever we need the plugin to _add_ stuff, we introduce a new `template_hook` in our [fork of Indico](https://github.com/UNOG-Indico/indico-core).
- Every now and then, we contribute a batch of newly added hooks upstream via PR.
- In the review process, some hooks may change name, move to a different location, or just be dismissed.
- Once the PR is merged, we update our fork and adapt the plugin to reflect these changes, overriding templates only then if necessary.

Would this work for you? Happy to hear alternatives to handle this.

---

<div class="post-metadata">

**Author:** ![ThiefMaster](https://talk.getindico.io/user_avatar/talk.getindico.io/thiefmaster/32/509_2.png) [@ThiefMaster](https://talk.getindico.io/u/ThiefMaster)\
**Post date:** [February 13, 2020, 11:20am UTC](https://talk.getindico.io/t/adding-template-hooks-in-core-rather-than-overriding-templates-in-plugin/1676/2 "2020-02-13T11:20:52Z")

</div>

I think whenever you can find a name for the hook that makes sense to others, then it’s a very good idea! (“unog-before-whatver” wouldn’t be ok in the core obviously, but “before-category-menu” would)

A PR adding a bunch of template hooks in one go sounds like a good idea for sure!

* * *

Adding template hooks whenever we needed them is basically what we did with the ones we have right now in the core - and that was always the idea: If someone wants to do something where a template hook is useful, contribute the hook and then use it in a plugin.
