1 Breadcrumbs (:mod:`cubicweb.web.views.ibreadcrumbs`) |
1 Breadcrumbs |
2 ---------------------------------------------------- |
2 ----------- |
3 XXX feedme |
3 |
|
4 Breadcrumbs are a navigation component to situate the user in the |
|
5 arborescence's site. |
|
6 |
|
7 |
|
8 Display |
|
9 ~~~~~~~ |
|
10 |
|
11 Breadcrumbs are displayed by default in the header section (see |
|
12 :ref:`the_main_template_sections`). With the default base template, |
|
13 the header section is composed by the logo, the application name, |
|
14 breadcrumbs and, at the most right, the login box. Breadcrumbs are |
|
15 displayed just next to the application name, thus breadcrumbs begin |
|
16 with a separator. |
|
17 |
|
18 Here is the header section of the CubicWeb's forge: |
|
19 |
|
20 .. image:: ../../../images/breadcrumbs_header.png |
|
21 |
|
22 There are three breadcrumbs components defined in |
|
23 ``cubicweb/web/views/ibreadcrumbs.py`` file: |
|
24 |
|
25 - BreadCrumbEntityVComponent: displayed for a result set with one line |
|
26 if the entity implements the ``IBreadCrumbs`` interface. |
|
27 - BreadCrumbETypeVComponent: displayed for a result set with more than |
|
28 one line, but with all entities of the same type which implement the |
|
29 ``IBreadCrumbs`` interface. |
|
30 - BreadCrumbAnyRSetVComponent: displayed for any other result set. |
|
31 |
|
32 Implementation |
|
33 ~~~~~~~~~~~~~~ |
|
34 |
|
35 The ``IBreadCrumbs`` interface is defined in the |
|
36 ``cubicweb/interfaces.py`` file. It specifies that an entity which |
|
37 implements this interface must have a ``breadcrumbs`` method. |
|
38 |
|
39 Here is the API of the ``breadcrumbs`` method: |
|
40 |
|
41 .. automethod:: cubicweb.interfaces.IBreadCrumbs.breadcrumbs |
|
42 |
|
43 |
|
44 If the breadcrumbs method return a list of entities, the |
|
45 ``cubicweb.web.views.ibreadcrumbs.BreadCrumbView`` is used to display |
|
46 the first elements and the |
|
47 ``cubicweb.web.views.ibreadcrumbs.BreadCrumbTextView`` is used to |
|
48 display the last one. |
|
49 |
|
50 By default, for any entity, if recurs=True, breadcrumbs method returns |
|
51 a list of entities, else a list of a simple string. |
|
52 |
|
53 In order to see a hierarchical breadcrumbs, entities must have a |
|
54 ``parent`` method which returns the parent entity. By default this |
|
55 method doesn't exist on entity, given that it can not be guessed. |
|
56 |
|
57 XXX To change the default separator, you have to monkeypatch the |
|
58 ``BreadCrumbEntityVComponent.separator`` class attribute. |
|
59 |
|
60 XXX add_to_breadcrumbs = False on an EntityView |