diff --git a/book/templates.rst b/book/templates.rst index 92e07339..2d783700 100644 --- a/book/templates.rst +++ b/book/templates.rst @@ -641,6 +641,12 @@ type: More details about blocks, such as the available parameters, can be found on the :doc:`reference <../reference/content-types/block>` page. +.. note:: + + If you want to use a block-type in multiple templates, you can define it as a + global block. More information about global blocks can be found in the + :ref:`templates-global-blocks` section. + Aligning Fields on the Grid --------------------------- @@ -885,6 +891,74 @@ You can also match multiple elements of different types. Use the wildcard +.. _templates-global-blocks: + +Using Global blocks +------------------- + +Global blocks define a set of properties that can be used as type inside of a block or any other property. This is +useful if you want to reuse a block type in multiple templates. + +To define a global block, you have to create a new XML file in the ``config/templates/blocks`` directory. The following +file is an example and defines a global block with the name ``text_block``: + +.. code-block:: xml + + + + +This block can be used in any other template by using the ```` or ```` element within the ``type`` +node and the ``ref`` attribute: + +.. code-block:: xml + + + + + + + Editor + Editor + + + + + Text Editor + Texteditor + + + + + + + Caching ------- diff --git a/reference/content-types/block.rst b/reference/content-types/block.rst index 2761cf68..38771f7f 100644 --- a/reference/content-types/block.rst +++ b/reference/content-types/block.rst @@ -115,6 +115,11 @@ editor as described in the description. +.. note:: + + If you want to use a block-type in multiple templates, you can use global blocks. See + :ref:`template properties ` for more information. + Twig ---- diff --git a/reference/content-types/image_map.rst b/reference/content-types/image_map.rst index 5c4a8e47..bf32b148 100644 --- a/reference/content-types/image_map.rst +++ b/reference/content-types/image_map.rst @@ -72,6 +72,11 @@ XML +.. note:: + + You can use global block-types also for the image_map content-type. See + :ref:`template properties ` for more information. + Twig ^^^^