doc/book/en/B1022-views-stdlib.en.txt
author sylvain.thenault@logilab.fr
Tue, 28 Apr 2009 11:22:43 +0200
branchtls-sprint
changeset 1499 fd8751c3f3ee
parent 1331 2335945523f5
permissions -rw-r--r--
install card cube in 3.2 migration
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
1331
2335945523f5 doc update
sylvain.thenault@logilab.fr
parents: 1280
diff changeset
     6
`CubicWeb` provides a lot of standard views. You can find them in
2335945523f5 doc update
sylvain.thenault@logilab.fr
parents: 1280
diff changeset
     7
``cubicweb/web/views/``.
1280
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
1331
2335945523f5 doc update
sylvain.thenault@logilab.fr
parents: 1280
diff changeset
    63
  
2335945523f5 doc update
sylvain.thenault@logilab.fr
parents: 1280
diff changeset
    64
Start view (e.g. views that don't apply to a result set):
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    65
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
    66
*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
    67
    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
    68
    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
    69
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
*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
    71
    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
    72
102
ef84f6b2e4cf [doc] Initial translation of views chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    73
Special views:
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    74
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
    75
*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
    76
    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
    77
    (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
    78
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
*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
    80
    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
    81
    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
    82
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
*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
    84
    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
    85
    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
    86
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
*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
    88
    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
    89
    `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
    90
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
*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
    92
    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
    93
    It is always applicable and it does not return anything