Allow Plugins to inject CSS or Javascript to HEAD section #9858

Closed
opened 2025-12-29 21:23:38 +01:00 by adam · 0 comments
Owner

Originally created by @PieterL75 on GitHub (Jun 17, 2024).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v4.0.5

Feature type

Data model extension

Proposed functionality

Provide a mean for a plugin to add its own content into the HEAD section of the page
This will make the CSS and Javascript available on all pages loaded.

netbox/templates/base/base.html

  • add {% load plugins %}
  • update the HEAD section to include {% plugin_base_head object %}

netbox/utilities/templatetags/plugins.py

  • extend with a def plugin_base_head(context, obj):

netbox/netbox/plugins/templates.py

  • extend class PluginTemplateExtension with def base_head(self)

Use case

Some plugins want to add content to all pages.
I'm using the 'BANNER_BOTTOM' to do this, and in newer version the middleware technique.
It would however be convenient for the plugin to have a native way to inject the JS and CSS.

Database changes

No response

External dependencies

No response

Originally created by @PieterL75 on GitHub (Jun 17, 2024). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v4.0.5 ### Feature type Data model extension ### Proposed functionality Provide a mean for a plugin to add its own content into the HEAD section of the page This will make the CSS and Javascript available on all pages loaded. netbox/templates/base/base.html - add `{% load plugins %}` - update the HEAD section to include `{% plugin_base_head object %}` netbox/utilities/templatetags/plugins.py - extend with a `def plugin_base_head(context, obj):` netbox/netbox/plugins/templates.py - extend `class PluginTemplateExtension` with `def base_head(self)` ### Use case Some plugins want to add content to all pages. I'm using the 'BANNER_BOTTOM' to do this, and in newer version the middleware technique. It would however be convenient for the plugin to have a native way to inject the JS and CSS. ### Database changes _No response_ ### External dependencies _No response_
adam added the status: acceptedtype: featuretopic: pluginsnetboxcomplexity: low labels 2025-12-29 21:23:38 +01:00
adam closed this issue 2025-12-29 21:23:38 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9858