doc/book/en/development/devweb/views/breadcrumbs.rst
author Aurelien Campeas <aurelien.campeas@logilab.fr>
Fri, 16 Apr 2010 13:57:27 +0200
branchstable
changeset 5309 e8567135a927
parent 5308 c691a424d9e0
child 5311 34dc38456376
permissions -rw-r--r--
[doc/book] fix docstrings, add notes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5308
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
     1
Breadcrumbs
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
     2
-----------
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
     3
5309
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
     4
Breadcrumbs are a navigation component to help the user locate himself
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
     5
along a path of entities.
5308
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
     6
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
     7
Display
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
     8
~~~~~~~
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
     9
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    10
Breadcrumbs are displayed by default in the header section (see
5309
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    11
:ref:`the_main_template_sections chapter`).  With the default main
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    12
template, the header section is composed by the logo, the application
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    13
name, breadcrumbs and, at the most right, the login box. Breadcrumbs
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    14
are displayed just next to the application name, thus breadcrumbs
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    15
begin with a separator.
5308
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    16
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    17
Here is the header section of the CubicWeb's forge:
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    18
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    19
.. image:: ../../../images/breadcrumbs_header.png
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    20
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    21
There are three breadcrumbs components defined in
5309
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    22
:mod:`cubicweb.web.views.ibreadcrumbs`:
5308
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    23
5309
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    24
- `BreadCrumbEntityVComponent`: displayed for a result set with one line
5308
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    25
  if the entity implements the ``IBreadCrumbs`` interface.
5309
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    26
- `BreadCrumbETypeVComponent`: displayed for a result set with more than
5308
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    27
  one line, but with all entities of the same type which implement the
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    28
  ``IBreadCrumbs`` interface.
5309
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    29
- `BreadCrumbAnyRSetVComponent`: displayed for any other result set.
5308
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    30
5309
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    31
Building breadcrumbs
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    32
~~~~~~~~~~~~~~~~~~~~
5308
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    33
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    34
The ``IBreadCrumbs`` interface is defined in the
5309
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    35
:mod:`cubicweb.interfaces` module. It specifies that an entity which
5308
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    36
implements this interface must have a ``breadcrumbs`` method.
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    37
5309
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    38
.. note::
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    39
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    40
   Redefining the breadcrumbs is the hammer way to do it. Another way
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    41
   is to define the `parent` method on an entity (as defined in the
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    42
   `ITree` interface). If available, it will be used to compute
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    43
   breadcrumbs.
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    44
5308
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    45
Here is the API of the ``breadcrumbs`` method:
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    46
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    47
.. automethod:: cubicweb.interfaces.IBreadCrumbs.breadcrumbs
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    48
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    49
If the breadcrumbs method return a list of entities, the
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    50
``cubicweb.web.views.ibreadcrumbs.BreadCrumbView`` is used to display
5309
e8567135a927 [doc/book] fix docstrings, add notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    51
the elements.
5308
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    52
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    53
By default, for any entity, if recurs=True, breadcrumbs method returns
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    54
a list of entities, else a list of a simple string.
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    55
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    56
In order to see a hierarchical breadcrumbs, entities must have a
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    57
``parent`` method which returns the parent entity. By default this
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5266
diff changeset
    58
method doesn't exist on entity, given that it can not be guessed.