author | Julien Cristau <julien.cristau@logilab.fr> |
Mon, 21 Dec 2015 15:44:20 +0100 | |
changeset 11010 | 09be4709c8c0 |
parent 10495 | 5bd914ebf3ae |
permissions | -rw-r--r-- |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
1 |
.. -*- coding: utf-8 -*- |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
2 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
3 |
.. _templates: |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
4 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
5 |
Templates |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
6 |
========= |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
7 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
8 |
Templates are the entry point for the |cubicweb| view system. As seen |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
9 |
in :ref:`views_base_class`, there are two kinds of views: the |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
10 |
templatable and non-templatable. |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
11 |
|
6302
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
12 |
|
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
13 |
Non-templatable views |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
14 |
--------------------- |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
15 |
|
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
16 |
Non-templatable views are standalone. They are responsible for all the details |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
17 |
such as setting a proper content type (or mime type), the proper document |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
18 |
headers, namespaces, etc. Examples are pure xml views such as RSS or Semantic Web |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
19 |
views (`SIOC`_, `DOAP`_, `FOAF`_, `Linked Data`_, etc.), and views which generate |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
20 |
binary files (pdf, excel files, etc.) |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
21 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
22 |
.. _`SIOC`: http://sioc-project.org/ |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
23 |
.. _`DOAP`: http://trac.usefulinc.com/doap |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
24 |
.. _`FOAF`: http://www.foaf-project.org/ |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
25 |
.. _`Linked Data`: http://linkeddata.org/ |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
26 |
|
6302
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
27 |
|
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
28 |
To notice that a view is not templatable, you just have to set the |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
29 |
view's class attribute `templatable` to `False`. In this case, it |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
30 |
should set the `content_type` class attribute to the correct MIME |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
31 |
type. By default, it is text/xhtml. Additionally, if your view |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
32 |
generate a binary file, you have to set the view's class attribute |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
33 |
`binary` to `True` too. |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
34 |
|
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
35 |
|
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
36 |
Templatable views |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
37 |
----------------- |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
38 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
39 |
Templatable views are not concerned with such pesky details. They |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
40 |
leave it to the template. Conversely, the template's main job is to: |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
41 |
|
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
42 |
* set up the proper document header and content type |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
43 |
* define the general layout of a document |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
44 |
* invoke adequate views in the various sections of the document |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
45 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
46 |
|
6302
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
47 |
Look at :mod:`cubicweb.web.views.basetemplates` and you will find the base |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
48 |
templates used to generate (X)HTML for your application. The most important |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
49 |
template there is :class:`~cubicweb.web.views.basetemplates.TheMainTemplate`. |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
50 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
51 |
.. _the_main_template_layout: |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
52 |
|
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
53 |
TheMainTemplate |
6302
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
54 |
~~~~~~~~~~~~~~~ |
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
55 |
|
5308
c691a424d9e0
[doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5290
diff
changeset
|
56 |
.. _the_main_template_sections: |
c691a424d9e0
[doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5290
diff
changeset
|
57 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
58 |
Layout and sections |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
59 |
``````````````````` |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
60 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
61 |
A page is composed as indicated on the schema below : |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
62 |
|
10495
5bd914ebf3ae
[doc] fix warnings/errors in doc build
Julien Cristau <julien.cristau@logilab.fr>
parents:
10491
diff
changeset
|
63 |
.. image:: ../../../images/main_template.png |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
64 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
65 |
The sections dispatches specific views: |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
66 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
67 |
* `header`: the rendering of the header is delegated to the |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
68 |
`htmlheader` view, whose default implementation can be found in |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
69 |
``basetemplates.py`` and which does the following things: |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
70 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
71 |
* inject the favicon if there is one |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
72 |
* inject the global style sheets and javascript resources |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
73 |
* call and display a link to an rss component if there is one available |
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1714
diff
changeset
|
74 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
75 |
it also sets up the page title, and fills the actual |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
76 |
`header` section with top-level components, using the `header` view, which: |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
77 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
78 |
* tries to display a logo, the name of the application and the `breadcrumbs` |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
79 |
* provides a login status area |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
80 |
* provides a login box (hiden by default) |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
81 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
82 |
* `left column`: this is filled with all selectable boxes matching the |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
83 |
`left` context (there is also a right column but nowadays it is |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
84 |
seldom used due to bad usability) |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
85 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
86 |
* `contentcol`: this is the central column; it is filled with: |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
87 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
88 |
* the `rqlinput` view (hidden by default) |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
89 |
* the `applmessages` component |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
90 |
* the `contentheader` view which in turns dispatches all available |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
91 |
content navigation components having the `navtop` context (this |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
92 |
is used to navigate through entities implementing the IPrevNext |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
93 |
interface) |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
94 |
* the view that was given as input to the template's `call` |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
95 |
method, also dealing with pagination concerns |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
96 |
* the `contentfooter` |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
97 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
98 |
* `footer`: adds all footer actions |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
99 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
100 |
.. note:: |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
101 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
102 |
How and why a view object is given to the main template is explained |
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
103 |
in the :ref:`publisher` chapter. |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
104 |
|
6302
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
105 |
Configure the main template |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
106 |
``````````````````````````` |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
107 |
|
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
108 |
You can overload some methods of the |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
109 |
:class:`~cubicweb.web.views.basetemplates.TheMainTemplate`, in order to fulfil |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
110 |
your needs. There are also some attributes and methods which can be defined on a |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
111 |
view to modify the base template behaviour: |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
112 |
|
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
113 |
* `paginable`: if the result set is bigger than a configurable size, your result |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
114 |
page will be paginated by default. You can set this attribute to `False` to |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
115 |
avoid this. |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
116 |
|
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
117 |
* `binary`: boolean flag telling if the view generates some text or a binary |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
118 |
stream. Default to False. When view generates text argument given to `self.w` |
10222
75d6096216d7
[docstrings] fix project-wide English language mistake
Dimitri Papadopoulos <dimitri.papadopoulos@cea.fr>
parents:
6880
diff
changeset
|
119 |
**must be a unicode string**, encoded string otherwise. |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
120 |
|
6302
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
121 |
* `content_type`, view's content type, default to 'text/xhtml' |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
122 |
|
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
123 |
* `templatable`, boolean flag telling if the view's content should be returned |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
124 |
directly (when `False`) or included in the main template layout (including |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
125 |
header, boxes and so on). |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
126 |
|
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
127 |
* `page_title()`, method that should return a title that will be set as page |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
128 |
title in the html headers. |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
129 |
|
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
130 |
* `html_headers()`, method that should return a list of HTML headers to be |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
131 |
included the html headers. |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
132 |
|
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
133 |
|
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
134 |
You can also modify certain aspects of the main template of a page |
10222
75d6096216d7
[docstrings] fix project-wide English language mistake
Dimitri Papadopoulos <dimitri.papadopoulos@cea.fr>
parents:
6880
diff
changeset
|
135 |
when building a url or setting these parameters in the req.form: |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
136 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
137 |
* `__notemplate`, if present (whatever the value assigned), only the content view |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
138 |
is returned |
6302
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
139 |
|
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
140 |
* `__force_display`, if present and its value is not null, no pagination whatever |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
141 |
the number of entities to display (e.g. similar effect as view's `paginable` |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
142 |
attribute described above. |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
143 |
|
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1714
diff
changeset
|
144 |
* `__method`, if the result set to render contains only one entity and this |
6302
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
145 |
parameter is set, it refers to a method to call on the entity by passing it the |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
146 |
dictionary of the forms parameters, before going the classic way (through step |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
147 |
1 and 2 described juste above) |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
148 |
|
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
149 |
* `vtitle`, a title to be set as <h1> of the content |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
150 |
|
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
151 |
Other templates |
6302
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
152 |
~~~~~~~~~~~~~~~ |
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
153 |
|
6302
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
154 |
There are also the following other standard templates: |
5284
ad922b7449aa
[doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5269
diff
changeset
|
155 |
|
6302
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
156 |
* :class:`cubicweb.web.views.basetemplates.LogInTemplate` |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
157 |
* :class:`cubicweb.web.views.basetemplates.LogOutTemplate` |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
158 |
* :class:`cubicweb.web.views.basetemplates.ErrorTemplate` specializes |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
159 |
:class:`~cubicweb.web.views.basetemplates.TheMainTemplate` to do |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
160 |
proper end-user output if an error occurs during the computation of |
ca5d09ff0379
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5394
diff
changeset
|
161 |
TheMainTemplate (it is a fallback view). |