Skip to content

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

Closed
@PieterL75

Description

@PieterL75

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

Metadata

Metadata

Assignees

Labels

complexity: lowRequires minimal effort to implementnetboxstatus: acceptedThis issue has been accepted for implementationtopic: pluginsRelates to the plugins frameworktype: featureIntroduction of new functionality to the application

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions