1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Clean up plugins documentation

This commit is contained in:
jeremystretch
2022-11-15 16:55:18 -05:00
parent 23077821f6
commit 0c0c848597
5 changed files with 20 additions and 15 deletions

View File

@ -16,7 +16,7 @@ menu = PluginMenu(
('Foo', (item1, item2, item3)),
('Bar', (item4, item5)),
),
icon='mdi mdi-router'
icon_class='mdi mdi-router'
)
```

View File

@ -1,5 +1,8 @@
# Search
!!! note
This feature was introduced in NetBox v3.4.
Plugins can define and register their own models to extend NetBox's core search functionality. Typically, a plugin will include a file named `search.py`, which holds all search indexes for its models (see the example below).
```python

View File

@ -156,6 +156,9 @@ These views are provided to enable or enhance certain NetBox model features, suc
### Additional Tabs
!!! note
This feature was introduced in NetBox v3.4.
Plugins can "attach" a custom view to a core NetBox model by registering it with `register_model_view()`. To include a tab for this view within the NetBox UI, declare a TabView instance named `tab`:
```python
@ -164,7 +167,7 @@ from myplugin.models import Stuff
from netbox.views import generic
from utilities.views import ViewTab, register_model_view
@register_model_view(Site, 'mview', path='some-other-stuff')
@register_model_view(Site, name='myview', path='some-other-stuff')
class MyView(generic.ObjectView):
...
tab = ViewTab(
@ -180,23 +183,22 @@ class MyView(generic.ObjectView):
### Extra Template Content
Plugins can inject custom content into certain areas of the detail views of applicable models. This is accomplished by subclassing `PluginTemplateExtension`, designating a particular NetBox model, and defining the desired methods to render custom content. Four methods are available:
Plugins can inject custom content into certain areas of core NetBox views. This is accomplished by subclassing `PluginTemplateExtension`, designating a particular NetBox model, and defining the desired method(s) to render custom content. Five methods are available:
* `left_page()` - Inject content on the left side of the page
* `right_page()` - Inject content on the right side of the page
* `full_width_page()` - Inject content across the entire bottom of the page
* `buttons()` - Add buttons to the top of the page
Plugins can also inject custom content into certain areas of the list views of applicable models using the same subclass of `PluginTemplateExtension`. One method is available:
* `list_buttons()` - Add buttons to the top of the list view page
| Method | View | Description |
|---------------------|-------------|-----------------------------------------------------|
| `left_page()` | Object view | Inject content on the left side of the page |
| `right_page()` | Object view | Inject content on the right side of the page |
| `full_width_page()` | Object view | Inject content across the entire bottom of the page |
| `buttons()` | Object view | Add buttons to the top of the page |
| `list_buttons()` | List view | Add buttons to the top of the page |
Additionally, a `render()` method is available for convenience. This method accepts the name of a template to render, and any additional context data you want to pass. Its use is optional, however.
When a PluginTemplateExtension is instantiated, context data is assigned to `self.context`. Available data include:
* `object` - The object being viewed (for detail views only)
* `model` - The model of the list view (for list views only)
* `object` - The object being viewed (object views only)
* `model` - The model of the list view (list views only)
* `request` - The current request
* `settings` - Global NetBox settings
* `config` - Plugin-specific configuration parameters