6 |
6 |
7 Display |
7 Display |
8 ~~~~~~~ |
8 ~~~~~~~ |
9 |
9 |
10 Breadcrumbs are displayed by default in the header section (see |
10 Breadcrumbs are displayed by default in the header section (see |
11 :ref:`the_main_template_sections`). With the default main |
11 :ref:`the_main_template_sections`). With the default main template, |
12 template, the header section is composed by the logo, the application |
12 the header section is composed by the logo, the application name, |
13 name, breadcrumbs and, at the most right, the login box. Breadcrumbs |
13 breadcrumbs and, at the most right, the login box. Breadcrumbs are |
14 are displayed just next to the application name, thus breadcrumbs |
14 displayed just next to the application name, thus they begin with a |
15 begin with a separator. |
15 separator. |
16 |
16 |
17 Here is the header section of the CubicWeb's forge: |
17 Here is the header section of the CubicWeb's forge: |
18 |
18 |
19 .. image:: ../../images/breadcrumbs_header.png |
19 .. image:: ../../images/breadcrumbs_header.png |
20 |
20 |
21 There are three breadcrumbs components defined in |
21 There are three breadcrumbs components defined in |
22 :mod:`cubicweb.web.views.ibreadcrumbs`: |
22 :mod:`cubicweb.web.views.ibreadcrumbs`: |
23 |
23 |
24 - `BreadCrumbEntityVComponent`: displayed for a result set with one line |
24 - `BreadCrumbEntityVComponent`: displayed for a result set with one line |
25 if the entity implements the ``IBreadCrumbs`` interface. |
25 if the entity is adaptable to ``IBreadCrumbsAdapter``. |
26 - `BreadCrumbETypeVComponent`: displayed for a result set with more than |
26 - `BreadCrumbETypeVComponent`: displayed for a result set with more than |
27 one line, but with all entities of the same type which implement the |
27 one line, but with all entities of the same type which can adapt to |
28 ``IBreadCrumbs`` interface. |
28 ``IBreadCrumbsAdapter``. |
29 - `BreadCrumbAnyRSetVComponent`: displayed for any other result set. |
29 - `BreadCrumbAnyRSetVComponent`: displayed for any other result set. |
30 |
30 |
31 Building breadcrumbs |
31 Building breadcrumbs |
32 ~~~~~~~~~~~~~~~~~~~~ |
32 ~~~~~~~~~~~~~~~~~~~~ |
33 |
33 |
34 The ``IBreadCrumbs`` interface is defined in the |
34 The ``IBreadCrumbsAdapter`` adapter is defined in the |
35 :mod:`cubicweb.interfaces` module. It specifies that an entity which |
35 :mod:`cubicweb.web.views.ibreadcrumbs` module. It specifies that an |
36 implements this interface must have a ``breadcrumbs`` method. |
36 entity which implements this interface must have a ``breadcrumbs`` and |
|
37 a ``parent_entity`` method. A default implementation for each is |
|
38 provided. This implementation expoits the ITreeAdapter. |
37 |
39 |
38 .. note:: |
40 .. note:: |
39 |
41 |
40 Redefining the breadcrumbs is the hammer way to do it. Another way |
42 Redefining the breadcrumbs is the hammer way to do it. Another way |
41 is to define the `parent` method on an entity (as defined in the |
43 is to define an `ITreeAdapter` adapter on an entity type. If |
42 `ITree` interface). If available, it will be used to compute |
44 available, it will be used to compute breadcrumbs. |
43 breadcrumbs. |
|
44 |
45 |
45 Here is the API of the ``breadcrumbs`` method: |
46 Here is the API of the ``IBreadCrumbsAdapter`` class: |
46 |
47 |
47 .. automethod:: cubicweb.interfaces.IBreadCrumbs.breadcrumbs |
48 .. automethod:: cubicweb.web.views.ibreadcrumbs.IBreadCrumbs.parent_entity |
|
49 .. automethod:: cubicweb.web.views.ibreadcrumbs.IBreadCrumbs.breadcrumbs |
48 |
50 |
49 If the breadcrumbs method return a list of entities, the |
51 If the breadcrumbs method return a list of entities, the |
50 ``cubicweb.web.views.ibreadcrumbs.BreadCrumbView`` is used to display |
52 ``cubicweb.web.views.ibreadcrumbs.BreadCrumbView`` is used to display |
51 the elements. |
53 the elements. |
52 |
54 |