-
Notifications
You must be signed in to change notification settings - Fork 66
Template Hooks
Janeway allows plugins to utilise hooks to insert HTML content into core templates. This allows you to add content without making changes directly to the core templates.
Hooks are loaded into templates using the hooks template tag located in core.templatetags.hooks
and can be included in templates by including the tags:
{% load hooks %}
{% hook 'name_of_hook_here' %}
Plugins are able to register for hooks by returning a dictionary in their plugin_settings.hook_registry
function that would look similar to:
def hook_registry():
# On site load, the load function is run for each installed plugin to generate
# a list of hooks.
return {'article_footer_block': {'module': 'plugins.disqus.hooks', 'function': 'inject_disqus'}}
This dictionary essentially says: When the article_footer_block hook is rendered in a template execute the inject_disqus
function that can be found in plugins.disqus.hooks
. A hook function should return HTML rendered either by Django's render
function or otherwise.
- press_admin_nav_block - appears in templates/press/nav.html
- journal_admin_nav_block - appears in templates/core/nav.html
- nav_block - appears in OLH or default/templates/core/nav.html
- article_footer_block - appears in OLH or default/tempaltes/core/article.html
- article_js_block - appears in OLH or default/tempaltes/core/article.html
- article_buttons - appears in OLH or default/tempaltes/core/article.html
Wiki has moved to read the docs.