author | Sandrine Ribeau <sandrine.ribeau@logilab.fr> |
Mon, 29 Dec 2008 14:43:38 -0800 | |
changeset 303 | ea6f0e833fbb |
parent 288 | 487bcc269d50 |
child 306 | 1ed1da008e50 |
permissions | -rw-r--r-- |
114
9ecd54ea0634
[doc] more chapters
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
1 |
.. -*- coding: utf-8 -*- |
9ecd54ea0634
[doc] more chapters
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
2 |
|
9ecd54ea0634
[doc] more chapters
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
3 |
Templates |
9ecd54ea0634
[doc] more chapters
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
4 |
========= |
9ecd54ea0634
[doc] more chapters
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
5 |
|
9ecd54ea0634
[doc] more chapters
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
6 |
[WRITE ME] |
9ecd54ea0634
[doc] more chapters
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
7 |
|
9ecd54ea0634
[doc] more chapters
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
8 |
* talk about main templates, etc. |
9ecd54ea0634
[doc] more chapters
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
9 |
|
199
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
10 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
11 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
12 |
Look at ``cubicweb/web/views/basetemplates.py`` and you will |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
13 |
find the base templates used to generate HTML for your application. |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
14 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
15 |
A page is composed as indicated on the schema below : |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
16 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
17 |
.. image:: images/lax-book.06-main-template-layout.en.png |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
18 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
19 |
In this section we will go through a couple of the primary templates |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
20 |
you must be interested in, that is to say, the HTMLPageHeader, |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
21 |
the HTMLPageFooter and the TheMainTemplate. |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
22 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
23 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
24 |
HTMLPageHeader |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
25 |
-------------- |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
26 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
27 |
Customize header |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
28 |
~~~~~~~~~~~~~~~~ |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
29 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
30 |
Let's now move the search box in the header and remove the login form |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
31 |
from the header. We'll show how to move it to the left column of the application. |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
32 |
|
273
5b3f9e09a6ea
[doc] Change logo has been moved to FAQ.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
199
diff
changeset
|
33 |
Let's say we do not want anymore the login menu to be in the header, but we |
199
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
34 |
prefer it to be in the left column just below the logo. As the left column is |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
35 |
rendered by ``TheMainTemplate``, we will show how to do it in TheMainTemplate_. |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
36 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
37 |
First, to remove the login menu, we just need to comment out the display of the |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
38 |
login component such as follows : :: |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
39 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
40 |
class MyHTMLPageHeader(HTMLPageHeader): |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
41 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
42 |
def main_header(self, view): |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
43 |
"""build the top menu with authentification info and the rql box""" |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
44 |
self.w(u'<table id="header"><tr>\n') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
45 |
self.w(u'<td id="firstcolumn">') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
46 |
self.vreg.select_component('logo', self.req, self.rset).dispatch(w=self.w) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
47 |
self.w(u'</td>\n') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
48 |
# appliname and breadcrumbs |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
49 |
self.w(u'<td id="headtext">') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
50 |
comp = self.vreg.select_component('appliname', self.req, self.rset) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
51 |
if comp and comp.propval('visible'): |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
52 |
comp.dispatch(w=self.w) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
53 |
comp = self.vreg.select_component('breadcrumbs', self.req, self.rset, view=view) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
54 |
if comp and comp.propval('visible'): |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
55 |
comp.dispatch(w=self.w, view=view) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
56 |
self.w(u'</td>') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
57 |
# logged user and help |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
58 |
#self.w(u'<td>\n') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
59 |
#comp = self.vreg.select_component('loggeduserlink', self.req, self.rset) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
60 |
#comp.dispatch(w=self.w) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
61 |
#self.w(u'</td><td>') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
62 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
63 |
self.w(u'<td>') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
64 |
helpcomp = self.vreg.select_component('help', self.req, self.rset) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
65 |
if helpcomp: # may not be available if Card is not defined in the schema |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
66 |
helpcomp.dispatch(w=self.w) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
67 |
self.w(u'</td>') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
68 |
# lastcolumn |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
69 |
self.w(u'<td id="lastcolumn">') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
70 |
self.w(u'</td>\n') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
71 |
self.w(u'</tr></table>\n') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
72 |
self.template('logform', rset=self.rset, id='popupLoginBox', klass='hidden', |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
73 |
title=False, message=False) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
74 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
75 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
76 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
77 |
.. image:: images/lax-book.06-header-no-login.en.png |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
78 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
79 |
Let's now move the search box in the top-right header area. To do so, we will |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
80 |
first create a method to get the search box display and insert it in the header |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
81 |
table. |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
82 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
83 |
:: |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
84 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
85 |
from ginco.web.views.basetemplates import HTMLPageHeader |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
86 |
class MyHTMLPageHeader(HTMLPageHeader): |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
87 |
def main_header(self, view): |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
88 |
"""build the top menu with authentification info and the rql box""" |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
89 |
self.w(u'<table id="header"><tr>\n') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
90 |
self.w(u'<td id="firstcolumn">') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
91 |
self.vreg.select_component('logo', self.req, self.rset).dispatch(w=self.w) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
92 |
self.w(u'</td>\n') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
93 |
# appliname and breadcrumbs |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
94 |
self.w(u'<td id="headtext">') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
95 |
comp = self.vreg.select_component('appliname', self.req, self.rset) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
96 |
if comp and comp.propval('visible'): |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
97 |
comp.dispatch(w=self.w) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
98 |
comp = self.vreg.select_component('breadcrumbs', self.req, self.rset, view=view) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
99 |
if comp and comp.propval('visible'): |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
100 |
comp.dispatch(w=self.w, view=view) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
101 |
self.w(u'</td>') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
102 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
103 |
# logged user and help |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
104 |
#self.w(u'<td>\n') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
105 |
#comp = self.vreg.select_component('loggeduserlink', self.req, self.rset) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
106 |
#comp.dispatch(w=self.w) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
107 |
#self.w(u'</td><td>') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
108 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
109 |
# search box |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
110 |
self.w(u'<td>') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
111 |
self.get_searchbox(view, 'left') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
112 |
self.w(u'</td>') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
113 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
114 |
self.w(u'<td>') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
115 |
helpcomp = self.vreg.select_component('help', self.req, self.rset) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
116 |
if helpcomp: # may not be available if Card is not defined in the schema |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
117 |
helpcomp.dispatch(w=self.w) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
118 |
self.w(u'</td>') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
119 |
# lastcolumn |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
120 |
self.w(u'<td id="lastcolumn">') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
121 |
self.w(u'</td>\n') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
122 |
self.w(u'</tr></table>\n') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
123 |
self.template('logform', rset=self.rset, id='popupLoginBox', klass='hidden', |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
124 |
title=False, message=False) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
125 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
126 |
def get_searchbox(self, view, context): |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
127 |
boxes = list(self.vreg.possible_vobjects('boxes', self.req, self.rset, |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
128 |
view=view, context=context)) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
129 |
if boxes: |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
130 |
for box in boxes: |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
131 |
if box.id == 'search_box': |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
132 |
box.dispatch(w=self.w, view=view) |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
133 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
134 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
135 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
136 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
137 |
HTMLPageFooter |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
138 |
-------------- |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
139 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
140 |
If you want to change the footer for example, look |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
141 |
for HTMLPageFooter and override it in your views file as in : |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
142 |
:: |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
143 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
144 |
form ginco.web.views.basetemplates import HTMLPageFooter |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
145 |
class MyHTMLPageFooter(HTMLPageFooter): |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
146 |
def call(self, **kwargs): |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
147 |
self.w(u'<div class="footer">') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
148 |
self.w(u'This website has been created with <a href="http://lax.logilab.org">LAX</a>.') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
149 |
self.w(u'</div>') |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
150 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
151 |
Updating a view does not require any restart of the server. By reloading |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
152 |
the page you can see your new page footer. |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
153 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
154 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
155 |
TheMainTemplate |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
156 |
--------------- |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
157 |
.. _TheMainTemplate: |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
158 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
159 |
The MainTemplate is a bit complex as it tries to accomodate many |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
160 |
different cases. We are now about to go through it and cutomize entirely |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
161 |
our application. |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
162 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
163 |
TheMainTemplate is responsible for the general layout of the entire application. |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
164 |
It defines the template of ``id = main`` that is used by the application. Is |
273
5b3f9e09a6ea
[doc] Change logo has been moved to FAQ.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
199
diff
changeset
|
165 |
also defined in ``cubicweb/web/views/basetemplates.py`` another template that can |
199
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
166 |
be used based on TheMainTemplate called SimpleMainTemplate which does not have |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
167 |
a top section. |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
168 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
169 |
.. image:: images/lax-book.06-simple-main-template.en.png |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
170 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
171 |
CSS changes |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
172 |
----------- |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
173 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
174 |
We cannot modify the order in which the application is reading the CSS. In |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
175 |
the case we want to create new CSS style, the best is to define it a in a new |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
176 |
CSS located under ``myapp/data/``. |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
177 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
178 |
If you want to modify an existing CSS styling property, you will have to use |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
179 |
``!important`` declaration to override the existing property. The application |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
180 |
apply a higher priority on the default CSS and you can not change that. |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
181 |
Customized CSS will not be read first. |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
182 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
183 |
1 |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
184 |
[TODO] |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
185 |
Add login menu in left column |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
186 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
187 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
188 |
[WRITE ME] |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
189 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
190 |
* customize MainTemplate and show that everything in the user |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
191 |
interface can be changed |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
192 |
|
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
193 |
[TODO] |
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
194 |
Rajouter une section pour definir la terminologie utilisee. |
273
5b3f9e09a6ea
[doc] Change logo has been moved to FAQ.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
199
diff
changeset
|
195 |
Dans ginco-doc rajouter une section pour cubciweb-ctl shell ou |
199
c603087373cd
[doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
196 |
on liste les commandes dispos. |