doc/book/en/B1022-views-stdlib.en.txt
author Emile Anclin <emile.anclin@logilab.fr>
Tue, 07 Apr 2009 10:46:40 +0200
changeset 1280 ebf1d748ed5a
parent 316 99943acb44af
child 1331 2335945523f5
permissions -rw-r--r--
[doc] Registerers are deprecated; little improvement
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     1
.. -*- coding: utf-8 -*-
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     2
102
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
     3
Predefined views in the library
316
99943acb44af [doc] Add sub-section about selectors and a little about registerer in views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 308
diff changeset
     4
```````````````````````````````
1280
ebf1d748ed5a [doc] Registerers are deprecated; little improvement
Emile Anclin <emile.anclin@logilab.fr>
parents: 316
diff changeset
     5
ebf1d748ed5a [doc] Registerers are deprecated; little improvement
Emile Anclin <emile.anclin@logilab.fr>
parents: 316
diff changeset
     6
`CubicWeb` provides a lot of standard views for the default class
ebf1d748ed5a [doc] Registerers are deprecated; little improvement
Emile Anclin <emile.anclin@logilab.fr>
parents: 316
diff changeset
     7
`EntityType`. You can find them in ``cubicweb/web/views/``.
ebf1d748ed5a [doc] Registerers are deprecated; little improvement
Emile Anclin <emile.anclin@logilab.fr>
parents: 316
diff changeset
     8
102
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
     9
A certain number of views are used to build the web interface, which apply
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    10
to one or more entities. Their identifier is what distinguish them from
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    11
each others and the main ones are:
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    12
308
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    13
*primary*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    14
    Primary view of an entity, this is the view called by default when a single
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    15
    non final entity is in the result set and needs to be displayed. 
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    16
    This view is supposed to render a maximum of informations about the entity.
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    17
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    18
*text*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    19
    This is the simplest text view for an entity. It displays the 
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    20
    title of an entity. It should not contain HTML.
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    21
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    22
*oneline*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    23
    This is a hyper linked *text* view. Similar to the `secondary` view, 
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    24
    but called when we want the view to stand on a single line, or just 
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    25
    get a brief view. By default this view uses the
102
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    26
    parameter `MAX_LINE_CHAR` to control the result size.
308
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    27
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    28
*secondary*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    29
    This is a combinaison of an icon and a *oneline* view.
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    30
    By default it renders the two first attributes of the entity as a 
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    31
    clickable link redirecting to the primary view.
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    32
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    33
*incontext, outofcontext*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    34
    Similar to the `secondary` view, but called when an entity is considered
102
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    35
    as in or out of context. By default it respectively returns the result of 
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    36
    `textincontext` and `textoutofcontext` wrapped in a link leading to 
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    37
    the primary view of the entity.
308
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    38
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    39
*textincontext, textoutofcontext*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    40
    Similar to the `text` view, but called when an entity is considered out or
102
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    41
    in context. By default it returns respectively the result of the 
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    42
    methods `.dc_title` and `.dc_long_title` of the entity.
308
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    43
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    44
*list*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    45
    This view displays a list of entities by creating a HTML list (`<ul>`) 
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    46
    and call the view `listitem` for each entity of the result set.
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    47
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    48
*listitem*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    49
    This view redirects by default to the `outofcontext` view.
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    50
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    51
*rss*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    52
    Creates a RSS/XML view and call the view `rssitem` for each entity of
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    53
    the result set.
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    54
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    55
*rssitem*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    56
    Create a RSS/XML view for each entity based on the results of the dublin core
102
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    57
    methods of the entity (`dc_*`)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    58
308
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    59
*sidebox*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    60
  This view displays usually a side box of some related entities 
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    61
  in a primary view.
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    62
102
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    63
Start view:
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    64
308
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    65
*index*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    66
    This view defines the home page of your application. It does not require
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    67
    a result set to apply to.
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    68
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    69
*schema*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    70
    A view dedicated to the display of the schema of the application
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    71
102
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    72
Special views:
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    73
308
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    74
*noresult*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    75
    This view is the default view used when no result has been found
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    76
    (e.g. empty result set).
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    77
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    78
*final*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    79
    Display the value of a cell without trasnformation (in case of a non final
102
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    80
    entity, we see the eid). Applicable on any result set.
308
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    81
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    82
*table*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    83
    Creates a HTML table (`<table>`) and call the view `cell` for each cell of
102
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    84
    the result set. Applicable on any result set.
308
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    85
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    86
*cell*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    87
    By default redirects to the `final` view if this is a final entity or
102
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    88
    `outofcontext` view otherwise
308
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    89
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    90
*null*
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    91
    This view is the default view used when nothing needs to be rendered.
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    92
    It is always applicable and it does not return anything