diff --git a/content/developer/howtos/website_themes/layout.rst b/content/developer/howtos/website_themes/layout.rst index 689771d95..2ef7ed5a6 100644 --- a/content/developer/howtos/website_themes/layout.rst +++ b/content/developer/howtos/website_themes/layout.rst @@ -212,28 +212,28 @@ below: .. tip:: -Using `move` directives inside an other XPath forces you to use only this kind of directives. + Using `move` directives inside an other XPath forces you to use only this kind of directives. -.. example:: - | **Good example:** + .. example:: + | **Good example:** - .. code-block:: xml + .. code-block:: xml - - - - -
-
+ + + + +
+
- | **Bad example:** + | **Bad example:** - .. code-block:: xml + .. code-block:: xml - - -
-
+ + +
+
.. seealso:: @@ -248,6 +248,60 @@ generate HTML fragments and pages. .. seealso:: :doc:`QWeb templates documentation <../../reference/frontend/qweb>`. +Custom fields +============= + +Depending on your needs, you can create custom fields to save data in the database. + +Declaration +----------- + +First, create a record to declare the field. This field has to be linked to an existing model. + +.. code-block:: xml + :caption: ``/website_airproof/data/fields.xml`` + + + x_post_category + ... + html + manual + 0 + + + +.. note:: Fields creation is also possible (and recommended) through `a model using Python `_. + +Back-end +-------- + +Add the field to the relevant view through an XPath. Therefore, the user can see the field in the +interface and fill it afterwards. + +.. code-block:: xml + :caption: ``/website_airproof/views/backend/website_blog_views.xml`` + + + view_blog_post_form_category + blog.post + + + + + + + + +Front-end +--------- + +The field value can be shown somewhere in a page by calling `model_name.field_name` like this: + +.. code-block:: xml + :caption: ``/website_airproof/views/website_blog_templates.xml`` + +

+ Background ========== @@ -293,6 +347,17 @@ Enable one of the header default templates. .. important:: Don't forget that you may need to disable the active header template first. + .. example:: + + .. code-block:: xml + :caption: ``/website_aiproof/data/presets.xml`` + + + + + +Explicitly set the desired template in the `primary_variables.scss` file. + .. code-block:: scss :caption: ``/website_airproof/static/src/scss/primary_variables.scss`` @@ -322,13 +387,13 @@ Create your own template and add it to the list. Use the following code to add an option for your new custom header on the Website Builder. .. code-block:: xml - :caption: ``/website_airproof/data/presets.xml`` + :caption: ``/website_airproof/views/website_templates.xml`` -