Important
You are browsing the documentation for version 4.1 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.
See our Release Process documentation for more information on the currently supported and upcoming releases.
TWIG Placeholders¶
Introduction to Placeholders¶
In order to improve layouts and make them more flexible, a new twig token placeholder is implemented. It enables us to combine several blocks (templates or actions) and output them in different places in twig templates. This way we can customize layouts without modifying twig templates.
Placeholder Declaration in YAML¶
Placeholders can be defined in any bundle under /SomeBundleName/Resource/oro/placeholders.yml
1 placeholders:
2 items: # items to use in placeholders (templates or actions)
3 <item_name>: # any unique identifier
4 template: <template> # path to custom template for renderer
5 <another_item_name>:
6 action: <action> # action name (e.g. OroSearchBundle:Search:searchBar)
7
8 placeholders:
9 <placeholder_name>:
10 items:
11 <item_name>:
12 order: 100 # sort order in placeholder
13 <another_item_name>:
14 order: 200
15 <one_more_item_name>: ~ # sort order will be set to 0
Any configuration defined in bundle placeholders.yml file can be overridden in the config/config.yml file.
1 oro_ui:
2 placeholders:
3 <placeholder_name>:
4 items:
5 <item_name>:
6 remove: true # remove item from placeholder
7 <another_placeholder_name>:
8 items:
9 <item_name>:
10 order: 200 # change item order in placeholder
Each placeholder item can have the following properties:
template or action - The path to TWIG template or controller action is used to rendering the item.
applicable - The condition indicates whether the item can be rendered or not.
acl - The ACL resource(s). Can be a string or array of strings. Can be used to restrict access to the item. If several ACL resources are provided an access is granted only if all of them grant an access.
data - An additional data to be passed to TWIG template or controller.
Each property can be a constant or some expression supported by System Aware Resolver Component. Examples can be found in existing placeholders.yml files.
Rendering Placeholders¶
To render placeholder content in twig template we need to put
1 {% placeholder <placeholder_name> %}
Additional options can be passed to all placeholder child items using with, e.g.
1{% placeholder <placeholder_name> with {'form' : form} %}