Document new blocks in login template

The old `branding.rst` docs were combined with the new docs on
customising the login page in a new `admin_templates.rst` document.
pull/2812/merge
Tim Heap 2016-11-28 11:45:01 +11:00 zatwierdzone przez Matt Westcott
rodzic 15c18e7f56
commit 2f8a43cd66
4 zmienionych plików z 82 dodań i 15 usunięć

Wyświetl plik

@ -17,6 +17,7 @@ Changelog
* Added new StreamField block type `StaticBlock` (Benoît Vogel)
* Updated Cloudflare cache module to use the v4 API (Albert O'Connor)
* Added `exclude_from_explorer` attribute to the `ModelAdmin` class to allow hiding instances of a page type from Wagtail's explorer views (Andy Babic)
* Added `above_login`, `below_login`, `fields` and `login_form` customisation blocks to the login page template (Tim Heap)
* Fix: `AbstractForm` now respects custom `get_template` methods on the page model (Gagaro)
* Fix: Use specific page model for the parent page in the explore index (Gagaro)
* Fix: Remove responsive styles in embed when there is no ratio available (Gagaro)

Wyświetl plik

@ -1,36 +1,44 @@
.. _custom_branding:
Custom branding
===============
===========================
Customising admin templates
===========================
In your projects with Wagtail, you may wish to replace elements such as the Wagtail logo within the admin interface with your own branding. This can be done through Django's template inheritance mechanism.
.. note::
Using ``{% extends %}`` in this way on a template you're currently overriding is only supported in Django 1.9 and above. On Django 1.8, you will need to use `django-overextends <https://github.com/stephenmcd/django-overextends>`_ instead.
You need to create a ``templates/wagtailadmin/`` folder within one of your apps - this may be an existing one, or a new one created for this purpose, for example, ``dashboard``. This app must be registered in ``INSTALLED_APPS`` before ``wagtail.wagtailadmin``::
You need to create a ``templates/wagtailadmin/`` folder within one of your apps - this may be an existing one, or a new one created for this purpose, for example, ``dashboard``. This app must be registered in ``INSTALLED_APPS`` before ``wagtail.wagtailadmin``:
.. code-block:: python
INSTALLED_APPS = (
# ...
'dashboard',
'wagtail.wagtailcore',
'wagtail.wagtailadmin',
# ...
)
The template blocks that are available to be overridden are as follows:
.. _custom_branding:
Custom branding
===============
The template blocks that are available to customise the branding in the admin interface are as follows:
``branding_logo``
-----------------
To replace the default logo, create a template file ``dashboard/templates/wagtailadmin/base.html`` that overrides the block ``branding_logo``::
To replace the default logo, create a template file ``dashboard/templates/wagtailadmin/base.html`` that overrides the block ``branding_logo``:
.. code-block:: html+django
{% extends "wagtailadmin/base.html" %}
{% load staticfiles %}
{% block branding_logo %}
<img src="{% static 'images/custom-logo.svg' %}" alt="Custom Project" width="80" />
{% endblock %}
@ -38,7 +46,9 @@ To replace the default logo, create a template file ``dashboard/templates/wagtai
``branding_favicon``
--------------------
To replace the favicon displayed when viewing admin pages, create a template file ``dashboard/templates/wagtailadmin/admin_base.html`` that overrides the block ``branding_favicon``::
To replace the favicon displayed when viewing admin pages, create a template file ``dashboard/templates/wagtailadmin/admin_base.html`` that overrides the block ``branding_favicon``:
.. code-block:: html+django
{% extends "wagtailadmin/admin_base.html" %}
{% load staticfiles %}
@ -50,7 +60,9 @@ To replace the favicon displayed when viewing admin pages, create a template fil
``branding_login``
------------------
To replace the login message, create a template file ``dashboard/templates/wagtailadmin/login.html`` that overrides the block ``branding_login``::
To replace the login message, create a template file ``dashboard/templates/wagtailadmin/login.html`` that overrides the block ``branding_login``:
.. code-block:: html+django
{% extends "wagtailadmin/login.html" %}
@ -59,8 +71,61 @@ To replace the login message, create a template file ``dashboard/templates/wagta
``branding_welcome``
--------------------
To replace the welcome message on the dashboard, create a template file ``dashboard/templates/wagtailadmin/home.html`` that overrides the block ``branding_welcome``::
To replace the welcome message on the dashboard, create a template file ``dashboard/templates/wagtailadmin/home.html`` that overrides the block ``branding_welcome``:
.. code-block:: html+django
{% extends "wagtailadmin/home.html" %}
{% block branding_welcome %}Welcome to Frank's Site{% endblock %}
Extending the login form
========================
To add extra controls to the login form, create a template file ``dashboard/templates/wagtailadmin/login.html``.
``above_login`` and ``below_login``
-----------------------------------
To add content above or below the login form, override these blocks:
.. code-block:: html+django
{% extends "wagtailadmin/login.html" %}
{% block above_login %} If you are not Frank you should not be here! {% endblock %}
``fields``
----------
To add extra fields to the login form, override the ``fields`` block. You will need to add ``{{ block.super }}`` somewhere in your block to include the username and password fields:
.. code-block:: html+django
{% extends "wagtailadmin/login.html" %}
{% block fields %}
{{ block.super }}
<li class="full">
<div class="field iconfield">
Two factor auth token
<div class="input icon-key">
<input type="text" name="two-factor-auth">
</div>
</div>
</li>
{% endblock %}
``login_form``
--------------
To completely customise the login form, override the ``login_form`` block. This block wraps the whole contents of the ``<form>`` element:
.. code-block:: html+django
{% extends "wagtailadmin/login.html" %}
{% block login_form %}
<p>Some extra form content</p>
{{ block.super }}
{% endblock %}

Wyświetl plik

@ -6,5 +6,5 @@ Customising Wagtail
:maxdepth: 2
page_editing_interface
branding
admin_templates
custom_user_models

Wyświetl plik

@ -42,7 +42,8 @@ Minor features
* Modeladmin forms now respect ``fields`` / ``exclude`` options passed on custom model forms (Thejaswi Puthraya)
* Added new StreamField block type ``StaticBlock`` for blocks that occupy a position in a stream but otherwise have no configuration; see :ref:`streamfield_staticblock` (Benoît Vogel)
* Updated Cloudflare cache module to use the v4 API (Albert O'Connor)
* Added `exclude_from_explorer` attribute to the `ModelAdmin` class to allow hiding instances of a page type from Wagtail's explorer views (Andy Babic)
* Added ``exclude_from_explorer`` attribute to the ``ModelAdmin`` class to allow hiding instances of a page type from Wagtail's explorer views (Andy Babic)
* Added ``above_login``, ``below_login``, ``fields`` and ``login_form`` customisation blocks to the login page template - see :doc:`/advanced_topics/customisation/admin_templates` (Tim Heap)
Bug fixes