mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
parent
8d7889e2c0
commit
a00144026b
@ -198,6 +198,7 @@ Plugins can inject custom content into certain areas of core NetBox views. This
|
||||
|
||||
| Method | View | Description |
|
||||
|---------------------|-------------|-----------------------------------------------------|
|
||||
| `head()` | All | Custom HTML `<head>` block includes |
|
||||
| `navbar()` | All | Inject content inside the top navigation bar |
|
||||
| `list_buttons()` | List view | Add buttons to the top of the page |
|
||||
| `buttons()` | Object view | Add buttons to the top of the page |
|
||||
|
@ -47,6 +47,13 @@ class PluginTemplateExtension:
|
||||
# Global methods
|
||||
#
|
||||
|
||||
def head(self):
|
||||
"""
|
||||
HTML returned by this method will be inserted in the page's `<head>` block. This may be useful e.g. for
|
||||
including additional Javascript or CSS resources.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def navbar(self):
|
||||
"""
|
||||
Content that will be rendered inside the top navigation menu. Content should be returned as an HTML
|
||||
|
@ -3,6 +3,9 @@ from netbox.plugins.templates import PluginTemplateExtension
|
||||
|
||||
class GlobalContent(PluginTemplateExtension):
|
||||
|
||||
def head(self):
|
||||
return "<!-- HEAD CONTENT -->"
|
||||
|
||||
def navbar(self):
|
||||
return "GLOBAL CONTENT - NAVBAR"
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
{% load helpers %}
|
||||
{% load i18n %}
|
||||
{% load django_htmx %}
|
||||
{% load plugins %}
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
lang="en"
|
||||
@ -59,6 +60,7 @@
|
||||
|
||||
{# Additional <head> content #}
|
||||
{% block head %}{% endblock %}
|
||||
{% plugin_head %}
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
@ -45,6 +45,14 @@ def _get_registered_content(obj, method, template_context):
|
||||
return mark_safe(html)
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def plugin_head(context):
|
||||
"""
|
||||
Render any <head> content embedded by plugins
|
||||
"""
|
||||
return _get_registered_content(None, 'head', context)
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def plugin_navbar(context):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user