@@ -114,19 +114,23 @@ web debug toolbar and in the web profiler. To do so, you need to create a Twig
114
114
template that includes some specific blocks.
115
115
116
116
In the simplest case, you just want to display the information in the toolbar
117
- without providing a profiler panel:
117
+ without providing a profiler panel. This requires to define the ``toolbar ``
118
+ block and set the value of two variables called ``icon `` and ``text ``:
118
119
119
120
.. code-block :: jinja
120
121
121
122
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
122
123
123
124
{% block toolbar %}
124
125
{% set icon %}
126
+ {# this is the content displayed as a panel in the toolbar #}
125
127
<span class="icon"><img src="..." alt=""/></span>
126
128
<span class="sf-toolbar-status">Information</span>
127
129
{% endset %}
128
130
129
131
{% set text %}
132
+ {# this is the content displayed when hovering the mouse over
133
+ the toolbar panel #}
130
134
<div class="sf-toolbar-info-piece">
131
135
<b>Quick piece of data</b>
132
136
<span>100 units</span>
@@ -137,16 +141,11 @@ without providing a profiler panel:
137
141
</div>
138
142
{% endset %}
139
143
140
- {# the 'link' value set to 'false' means that this panel doesn't show
141
- a section in the web profiler. #}
144
+ {# the 'link' value set to 'false' means that this panel doesn't
145
+ show a section in the web profiler. #}
142
146
{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: false }) }}
143
147
{% endblock %}
144
148
145
- The ``toolbar `` block is used to create a panel in the web debug toolbar. The
146
- inner ``icon `` block defines the content to display right inside the toolbar
147
- and the ``text `` block defines the content displayed when hovering the mouse
148
- over that same panel.
149
-
150
149
.. tip ::
151
150
152
151
Built-in collector templates define all their images as embedded base64-encoded
@@ -157,7 +156,15 @@ over that same panel.
157
156
158
157
<img src =" data:image/png;base64,..." />
159
158
160
- You are encouraged to use this same technique for your own toolbar panels.
159
+ Another solution is to define the images as SVG files. In addition to being
160
+ resolution-independent, these images can be easily embedded in the Twig
161
+ template or included from an external file to reuse them in several templates:
162
+
163
+ .. code-block :: jinja
164
+
165
+ {{ include('@WebProfiler/Icon/my_collector.svg') }}
166
+
167
+ You are encouraged to use the latter technique for your own toolbar panels.
161
168
162
169
If the toolbar panel includes extended web profiler information, the Twig template
163
170
must also define other blocks:
@@ -179,12 +186,14 @@ must also define other blocks:
179
186
{% endset %}
180
187
181
188
{# the 'link' value is now set to 'true', which allows the user to click
182
- on it to access to the web profiler panel. #}
189
+ on it to access to the web profiler panel. Since 'true' is the default
190
+ value, you can omit the 'link' parameter entirely #}
183
191
{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: true }) }}
184
192
{% endblock %}
185
193
186
194
{% block head %}
187
195
{# Optional, here you can link to or define your own CSS and JS contents #}
196
+ {# Use {{ parent() }} to keep the default styles #}
188
197
{% endblock %}
189
198
190
199
{% block menu %}
0 commit comments