Skip to content

Commit 3c32c97

Browse files
committed
Implemented all suggestions
1 parent 7efe30c commit 3c32c97

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

cookbook/profiler/data_collector.rst

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,23 @@ web debug toolbar and in the web profiler. To do so, you need to create a Twig
114114
template that includes some specific blocks.
115115

116116
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``:
118119

119120
.. code-block:: jinja
120121
121122
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
122123
123124
{% block toolbar %}
124125
{% set icon %}
126+
{# this is the content displayed as a panel in the toolbar #}
125127
<span class="icon"><img src="..." alt=""/></span>
126128
<span class="sf-toolbar-status">Information</span>
127129
{% endset %}
128130
129131
{% set text %}
132+
{# this is the content displayed when hovering the mouse over
133+
the toolbar panel #}
130134
<div class="sf-toolbar-info-piece">
131135
<b>Quick piece of data</b>
132136
<span>100 units</span>
@@ -137,16 +141,11 @@ without providing a profiler panel:
137141
</div>
138142
{% endset %}
139143
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. #}
142146
{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: false }) }}
143147
{% endblock %}
144148
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-
150149
.. tip::
151150

152151
Built-in collector templates define all their images as embedded base64-encoded
@@ -157,7 +156,15 @@ over that same panel.
157156

158157
<img src="data:image/png;base64,..." />
159158

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.
161168

162169
If the toolbar panel includes extended web profiler information, the Twig template
163170
must also define other blocks:
@@ -179,12 +186,14 @@ must also define other blocks:
179186
{% endset %}
180187
181188
{# 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 #}
183191
{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: true }) }}
184192
{% endblock %}
185193
186194
{% block head %}
187195
{# Optional, here you can link to or define your own CSS and JS contents #}
196+
{# Use {{ parent() }} to keep the default styles #}
188197
{% endblock %}
189198
190199
{% block menu %}

0 commit comments

Comments
 (0)