Commit dc49d1d79eaae548896177dc12d1f85f53b2d9a9
1 parent
faa3e9d2
Exists in
master
and in
4 other branches
Documenting new template tag for widgets
Showing
1 changed file
with
29 additions
and
0 deletions
Show diff stats
docs/source/dev.rst
@@ -48,3 +48,32 @@ Example Widget: | @@ -48,3 +48,32 @@ Example Widget: | ||
48 | self.content = processed_content | 48 | self.content = processed_content |
49 | 49 | ||
50 | To add the widget in a view check the Widgets section in User Documentation. | 50 | To add the widget in a view check the Widgets section in User Documentation. |
51 | +To use a widget in the templates, you have to use the ``import_widget`` tag inside the ``html`` block. | ||
52 | +You can also set the variable that the widgets of an area will be imported. | ||
53 | +Or you can use the default name, which is ``widgets_area_name``. | ||
54 | +For example, in the ``profile`` area the variable name is ``widgets_profile``. | ||
55 | +This variable will be inserted directly in the page ``context``. | ||
56 | + | ||
57 | +.. code-block:: python | ||
58 | + | ||
59 | + {% load widgets_tag %} | ||
60 | + | ||
61 | + {% block html %} | ||
62 | + {% import_widgets 'profile' %} | ||
63 | + {{ block.super }} | ||
64 | + {% endblock %} | ||
65 | + | ||
66 | + {# example of how to use #} | ||
67 | + {% block head %} | ||
68 | + {{ block.super }} | ||
69 | + | ||
70 | + {% for widget in widgets_profile %} | ||
71 | + {{ widget.get_header }} | ||
72 | + {% endfor %} | ||
73 | + | ||
74 | + {% endblock %} | ||
75 | + | ||
76 | + | ||
77 | +.. warning:: | ||
78 | + | ||
79 | + Warning! Remember to use the tag ``{{ block.super }}`` inside the html block. Otherwise, the page will appear blank. |