doc/book/en/B1060-templates.en.txt
author Graziella Toutoungis <graziella.toutoungis@logilab.fr>
Tue, 31 Mar 2009 17:09:38 +0200
changeset 1194 e224f064a268
parent 1191 216141cf47a3
child 1222 0d5035525a23
permissions -rw-r--r--
optimize this code part
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
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: 306
diff changeset
     3
.. _templates:
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
     4
114
9ecd54ea0634 [doc] more chapters
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     5
Templates
9ecd54ea0634 [doc] more chapters
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     6
=========
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
[WRITE ME]
9ecd54ea0634 [doc] more chapters
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     9
9ecd54ea0634 [doc] more chapters
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    10
* talk about main templates, etc.
9ecd54ea0634 [doc] more chapters
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    11
199
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    12
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    13
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    14
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
    15
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
    16
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    17
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
    18
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    19
.. 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
    20
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    21
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
    22
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
    23
the HTMLPageFooter and the TheMainTemplate.
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    24
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
HTMLPageHeader
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    27
--------------
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
Customize header
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    30
~~~~~~~~~~~~~~~~
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    31
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    32
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
    33
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
    34
273
5b3f9e09a6ea [doc] Change logo has been moved to FAQ.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 199
diff changeset
    35
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
    36
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
    37
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
    38
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    39
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
    40
login component such as follows : ::
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
  class MyHTMLPageHeader(HTMLPageHeader):
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    43
    
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    44
      def main_header(self, view):
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    45
          """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
    46
          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
    47
          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
    48
          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
    49
          self.w(u'</td>\n')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    50
          # appliname and breadcrumbs
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    51
          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
    52
          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
    53
          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
    54
              comp.dispatch(w=self.w)
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    55
          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
    56
          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
    57
              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
    58
          self.w(u'</td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    59
          # logged user and help
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    60
          #self.w(u'<td>\n')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    61
          #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
    62
          #comp.dispatch(w=self.w)
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    63
          #self.w(u'</td><td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    64
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    65
          self.w(u'<td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    66
          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
    67
          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
    68
              helpcomp.dispatch(w=self.w)
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    69
          self.w(u'</td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    70
          # lastcolumn
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    71
          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
    72
          self.w(u'</td>\n')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    73
          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
    74
          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
    75
                        title=False, message=False)
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
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
.. 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
    80
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    81
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
    82
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
    83
table.
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
::
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    86
1191
216141cf47a3 remove all erudi and ginco occurences in the doc
Emile Anclin <emile.anclin@logilab.fr>
parents: 856
diff changeset
    87
 from cubicweb.web.views.basetemplates import HTMLPageHeader
199
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    88
 class MyHTMLPageHeader(HTMLPageHeader):
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    89
    def main_header(self, view):
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    90
        """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
    91
        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
    92
        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
    93
        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
    94
        self.w(u'</td>\n')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    95
        # appliname and breadcrumbs
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    96
        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
    97
        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
    98
        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
    99
            comp.dispatch(w=self.w)
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   100
        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
   101
        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
   102
            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
   103
        self.w(u'</td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   104
        
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   105
        # logged user and help
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   106
        #self.w(u'<td>\n')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   107
        #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
   108
        #comp.dispatch(w=self.w)
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   109
        #self.w(u'</td><td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   110
        
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   111
        # search box
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
        self.get_searchbox(view, 'left')
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
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   116
        self.w(u'<td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   117
        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
   118
        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
   119
            helpcomp.dispatch(w=self.w)
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   120
        self.w(u'</td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   121
        # lastcolumn
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   122
        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
   123
        self.w(u'</td>\n')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   124
        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
   125
        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
   126
                      title=False, message=False)
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   127
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   128
    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
   129
        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
   130
                                                 view=view, context=context))
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   131
        if boxes:
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   132
            for box in boxes:
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   133
                if box.id == 'search_box':
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   134
                    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
   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
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
HTMLPageFooter
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   140
--------------
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   141
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   142
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
   143
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
   144
::
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   145
1191
216141cf47a3 remove all erudi and ginco occurences in the doc
Emile Anclin <emile.anclin@logilab.fr>
parents: 856
diff changeset
   146
  form cubicweb.web.views.basetemplates import HTMLPageFooter
199
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   147
  class MyHTMLPageFooter(HTMLPageFooter):
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   148
      def call(self, **kwargs):
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   149
          self.w(u'<div class="footer">')
306
1ed1da008e50 [doc] Removes references to LAX.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 288
diff changeset
   150
          self.w(u'This website has been created with <a href="http://cubicweb.org">CubicWeb</a>.')
199
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   151
          self.w(u'</div>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   152
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   153
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
   154
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
   155
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
.. _TheMainTemplate:
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   160
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: 306
diff changeset
   161
TheMainTemplate is responsible for the general layout of the entire application. 
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   162
It defines the template of ``id = main`` that is used by the application.
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   163
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   164
The default main template (`cubicweb.web.views.basetemplates.TheMainTemplate`)
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   165
builds the page based on the following pattern:
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   166
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   167
.. image:: images/main_template_layout.png
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   168
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   169
The rectangle containing `view.dispatch()` represents the area where the content
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   170
view has to be displayed. The others represents sub-templates called to complete
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   171
the page. A default implementation of those is provided in 
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   172
`cubicweb.views.basetemplates`. You can, of course, overload those sub-templates
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   173
to implement your own customization of the HTML page.
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   174
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   175
We can also control certain aspects of the main template thanks to the following
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   176
forms parameters:
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   177
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   178
* `__notemplate`, if present (whatever the value assigned), only the content 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: 306
diff changeset
   179
  is returned
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   180
* `__force_display`, if present and its value is not null, no navigation 
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   181
  whatever the number of entities to display
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   182
* `__method`, if the result set to render contains only one entity and this 
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   183
  parameter is set, it refers to a method to call on the entity by passing it
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   184
  the dictionnary of the forms parameters, before going the classic way (through
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   185
  step 1 and 2 described juste above)
73a352526577 [doc] Improvement to the Views chapter. Moved content about the main template in the Templates chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 306
diff changeset
   186
199
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   187
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
   188
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
   189
our application.
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   190
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   191
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   192
CSS changes
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   193
-----------
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   194
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   195
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
   196
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
   197
CSS located under ``myapp/data/``.
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   198
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   199
856
fdd1743c57ce ask for translation from french
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 308
diff changeset
   200
.. [TRANSLATE ME FROM FRENCH]
fdd1743c57ce ask for translation from french
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 308
diff changeset
   201
.. 03-XX-external_resources.fr.txt
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: 306
diff changeset
   202
199
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   203
[TODO]
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   204
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
   205
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   206
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   207
[WRITE ME]
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   208
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   209
* 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
   210
  interface can be changed
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   211
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   212
[TODO]
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   213
Rajouter une section pour definir la terminologie utilisee.
1191
216141cf47a3 remove all erudi and ginco occurences in the doc
Emile Anclin <emile.anclin@logilab.fr>
parents: 856
diff changeset
   214
Dans cubicweb-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
   215
on liste les commandes dispos.