kopia lustrzana https://github.com/wagtail/wagtail
Moved "setting up the page editor interface" into topics
rodzic
deee02e4d7
commit
f72b8302f9
|
@ -1,54 +1,5 @@
|
|||
.. _editing-api:
|
||||
|
||||
Setting up the page editor interface
|
||||
====================================
|
||||
|
||||
Wagtail provides a highly-customisable editing interface consisting of several components:
|
||||
|
||||
* **Fields** — built-in content types to augment the basic types provided by Django
|
||||
* **Panels** — the basic editing blocks for fields, groups of fields, and related object clusters
|
||||
* **Choosers** — interfaces for finding related objects in a ForeignKey relationship
|
||||
|
||||
Configuring your models to use these components will shape the Wagtail editor to your needs. Wagtail also provides an API for injecting custom CSS and JavaScript for further customisation, including extending the ``hallo.js`` rich text editor.
|
||||
|
||||
There is also an Edit Handler API for creating your own Wagtail editor components.
|
||||
|
||||
Defining Panels
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
A "panel" is the basic editing block in Wagtail. Wagtail will automatically pick the appropriate editing widget for most Django field types; implementers just need to add a panel for each field they want to show in the Wagtail page editor, in the order they want them to appear.
|
||||
|
||||
Wagtail provides a tabbed interface to help organise panels. Three such tabs are provided:
|
||||
|
||||
* ``content_panels`` is the main tab, used for the bulk of your model's fields.
|
||||
* ``promote_panels`` is suggested for organising fields regarding the promotion of the page around the site and the Internet. For example, a field to dictate whether the page should show in site-wide menus, descriptive text that should appear in site search results, SEO-friendly titles, OpenGraph meta tag content and other machine-readable information.
|
||||
* ``settings_panels`` is essentially for non-copy fields. By default it contains the page's scheduled publishing fields. Other suggested fields could include a field to switch between one layout/style and another.
|
||||
|
||||
Let's look at an example of a panel definition:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class ExamplePage(Page):
|
||||
# field definitions omitted
|
||||
...
|
||||
|
||||
content_panels = Page.content_panels + [
|
||||
FieldPanel('body', classname="full"),
|
||||
FieldRowPanel([
|
||||
FieldPanel('start_date', classname="col3"),
|
||||
FieldPanel('end_date', classname="col3"),
|
||||
]),
|
||||
ImageChooserPanel('splash_image'),
|
||||
DocumentChooserPanel('free_download'),
|
||||
PageChooserPanel('related_page'),
|
||||
]
|
||||
|
||||
promote_panels = [
|
||||
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
|
||||
]
|
||||
|
||||
After the :class:`~wagtail.wagtailcore.models.Page`-derived class definition, just add lists of panel definitions to order and organise the Wagtail page editing interface for your model.
|
||||
|
||||
Available panel types
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -59,6 +59,54 @@ Below that the ``content_panels`` and ``promote_panels`` lists define the capabi
|
|||
|
||||
Your models may be even more complex, with methods overriding the built-in functionality of the :class:`~wagtail.wagtailcore.models.Page` to achieve webdev magic. Or, you can keep your models simple and let Wagtail's built-in functionality do the work.
|
||||
|
||||
Setting up the page editor interface
|
||||
====================================
|
||||
|
||||
Wagtail provides a highly-customisable editing interface consisting of several components:
|
||||
|
||||
* **Fields** — built-in content types to augment the basic types provided by Django
|
||||
* **Panels** — the basic editing blocks for fields, groups of fields, and related object clusters
|
||||
* **Choosers** — interfaces for finding related objects in a ForeignKey relationship
|
||||
|
||||
Configuring your models to use these components will shape the Wagtail editor to your needs. Wagtail also provides an API for injecting custom CSS and JavaScript for further customisation, including extending the ``hallo.js`` rich text editor.
|
||||
|
||||
There is also an Edit Handler API for creating your own Wagtail editor components.
|
||||
|
||||
Defining Panels
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
A "panel" is the basic editing block in Wagtail. Wagtail will automatically pick the appropriate editing widget for most Django field types; implementers just need to add a panel for each field they want to show in the Wagtail page editor, in the order they want them to appear.
|
||||
|
||||
Wagtail provides a tabbed interface to help organise panels. Three such tabs are provided:
|
||||
|
||||
* ``content_panels`` is the main tab, used for the bulk of your model's fields.
|
||||
* ``promote_panels`` is suggested for organising fields regarding the promotion of the page around the site and the Internet. For example, a field to dictate whether the page should show in site-wide menus, descriptive text that should appear in site search results, SEO-friendly titles, OpenGraph meta tag content and other machine-readable information.
|
||||
* ``settings_panels`` is essentially for non-copy fields. By default it contains the page's scheduled publishing fields. Other suggested fields could include a field to switch between one layout/style and another.
|
||||
|
||||
Let's look at an example of a panel definition:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class ExamplePage(Page):
|
||||
# field definitions omitted
|
||||
...
|
||||
|
||||
content_panels = Page.content_panels + [
|
||||
FieldPanel('body', classname="full"),
|
||||
FieldRowPanel([
|
||||
FieldPanel('start_date', classname="col3"),
|
||||
FieldPanel('end_date', classname="col3"),
|
||||
]),
|
||||
ImageChooserPanel('splash_image'),
|
||||
DocumentChooserPanel('free_download'),
|
||||
PageChooserPanel('related_page'),
|
||||
]
|
||||
|
||||
promote_panels = [
|
||||
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
|
||||
]
|
||||
|
||||
After the :class:`~wagtail.wagtailcore.models.Page`-derived class definition, just add lists of panel definitions to order and organise the Wagtail page editing interface for your model.
|
||||
|
||||
Tips
|
||||
~~~~
|
||||
|
|
Ładowanie…
Reference in New Issue