Layout plugins

Layout plugins are simpler than component plugins because usually they do not contain code, but only views and static files. Yet you should still follow good practice:

First, create a folder called “static/plugin_layout_name/“ (where name is the name of your layout) and place all your static files there.

Second, create a layout file called “views/plugin_layout_name/layout.html” that contains your layout and links the images, CSS and JavaScript files in “static/plugin_layout_name/“

Third, modify the “views/layout.html” so that it simply reads:

  1. {{extend 'plugin_layout_name/layout.html'}}
  2. {{include}}

The benefit of this design is that users of this plugin can install multiple layouts and choose which one to apply simply by editing “views/layout.html”. Moreover, “views/layout.html” will not be packed by admin together with the plugin, so there is no risk that the plugin will override the user’s code in the previously installed layout.