doc/book/en/BXXX-templates.en.txt
author Nicolas Chauvat <nicolas.chauvat@logilab.fr>
Mon, 22 Dec 2008 19:54:30 +0100
changeset 268 0575e7973c5e
parent 199 c603087373cd
child 273 5b3f9e09a6ea
permissions -rw-r--r--
[doc] trying to improve the tutorial
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
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
Let's use a different logo than the default one provided with LAX
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    28
and customize our header.
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
Customize header
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
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    33
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
    34
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
    35
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    36
Let's sat we do not want anymore the login menu to be in the header, but we 
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    37
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
    38
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
    39
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    40
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
    41
login component such as follows : ::
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    42
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    43
  class MyHTMLPageHeader(HTMLPageHeader):
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    44
    
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    45
      def main_header(self, view):
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    46
          """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
    47
          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
    48
          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
    49
          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
    50
          self.w(u'</td>\n')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    51
          # appliname and breadcrumbs
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    52
          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
    53
          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
    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)
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    56
          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
    57
          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
    58
              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
    59
          self.w(u'</td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    60
          # logged user and help
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    61
          #self.w(u'<td>\n')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    62
          #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
    63
          #comp.dispatch(w=self.w)
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    64
          #self.w(u'</td><td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    65
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    66
          self.w(u'<td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    67
          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
    68
          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
    69
              helpcomp.dispatch(w=self.w)
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    70
          self.w(u'</td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    71
          # 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 id="lastcolumn">')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    73
          self.w(u'</td>\n')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    74
          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
    75
          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
    76
                        title=False, message=False)
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
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    80
.. 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
    81
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    82
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
    83
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
    84
table.
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
::
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    87
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    88
 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
    89
 class MyHTMLPageHeader(HTMLPageHeader):
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    90
    def main_header(self, view):
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    91
        """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
    92
        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
    93
        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
    94
        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
    95
        self.w(u'</td>\n')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    96
        # appliname and breadcrumbs
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
    97
        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
    98
        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
    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)
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   101
        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
   102
        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
   103
            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
   104
        self.w(u'</td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   105
        
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   106
        # logged user and help
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   107
        #self.w(u'<td>\n')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   108
        #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
   109
        #comp.dispatch(w=self.w)
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   110
        #self.w(u'</td><td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   111
        
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   112
        # search box
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   113
        self.w(u'<td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   114
        self.get_searchbox(view, 'left')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   115
        self.w(u'</td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   116
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   117
        self.w(u'<td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   118
        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
   119
        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
   120
            helpcomp.dispatch(w=self.w)
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   121
        self.w(u'</td>')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   122
        # 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 id="lastcolumn">')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   124
        self.w(u'</td>\n')
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   125
        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
   126
        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
   127
                      title=False, message=False)
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   128
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   129
    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
   130
        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
   131
                                                 view=view, context=context))
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   132
        if boxes:
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   133
            for box in boxes:
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   134
                if box.id == 'search_box':
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   135
                    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
   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
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   140
HTMLPageFooter
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
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   143
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
   144
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
   145
::
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   146
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   147
  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
   148
  class MyHTMLPageFooter(HTMLPageFooter):
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   149
      def call(self, **kwargs):
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   150
          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
   151
          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
   152
          self.w(u'</div>')
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
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
   155
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
   156
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   157
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   158
TheMainTemplate
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   159
---------------
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   160
.. _TheMainTemplate:
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   161
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   162
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
   163
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
   164
our application.
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   165
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   166
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
   167
It defines the template of ``id = main`` that is used by the application. Is 
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   168
also defined in ``ginco/web/views/basetemplates.py`` another template that can
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   169
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
   170
a top section.
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   171
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   172
.. 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
   173
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   174
CSS changes
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   175
-----------
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   176
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   177
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
   178
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
   179
CSS located under ``myapp/data/``.
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   180
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   181
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
   182
``!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
   183
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
   184
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
   185
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   186
1
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   187
[TODO]
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   188
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
   189
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
[WRITE ME]
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
* 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
   194
  interface can be changed
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   195
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   196
[TODO]
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   197
Rajouter une section pour definir la terminologie utilisee.
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   198
Dans ginco-doc rajouter une section pour erudi-ctl shell ou
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   199
on liste les commandes dispos.