diff -r b4befa12bbcc -r 87e2641d75f7 doc/book/en/tutorials/base/maintemplate.rst --- a/doc/book/en/tutorials/base/maintemplate.rst Mon Jan 17 12:42:27 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,131 +0,0 @@ -.. -*- coding: utf-8 -*- - -Templates ---------- - -Look at ``cubicweb/web/views/basetemplates.py`` and you will -find the base templates used to generate HTML for your application. - -A page is composed as indicated on the schema below: - -.. image:: ../../images/lax-book_06-main-template-layout_en.png - -In this section we will demonstrate a change in one of the main -interesting template from the three you will look for, -that is to say, the HTMLPageHeader, the HTMLPageFooter -and the TheMainTemplate. - - -Customize a template -~~~~~~~~~~~~~~~~~~~~ - -Based on the diagram below, each template can be overriden -by your customized template. To do so, we recommand you create -a Python module ``blog.views.templates`` to keep it organized. -In this module you will have to import the parent class you are -interested as follows: :: - - from cubicweb.web.views.basetemplates import HTMLPageHeader, \ - HTMLPageFooter, TheMainTemplate - -and then create your sub-class:: - - class MyBlogHTMLPageHeader(HTMLPageHeader): - ... - -Customize header -````````````````` - -Let's now move the search box in the header and remove the login form from the -header. We'll show how to move it to the left column of the user interface. - -Let's say we do not want anymore the login menu to be in the header - -First, to remove the login menu, we just need to comment out the display of the -login graphic component such as follows: - -.. sourcecode:: python - - class MyBlogHTMLPageHeader(HTMLPageHeader): - - def main_header(self, view): - """build the top menu with authentification info and the rql box""" - self.w(u'
') - self._cw.vreg.select_component('logo', self._cw, self.cw_rset).dispatch(w=self.w) - self.w(u' | \n') - # appliname and breadcrumbs - self.w(u'') - comp = self._cw.vreg.select_component('appliname', self._cw, self.cw_rset) - if comp and comp.propval('visible'): - comp.dispatch(w=self.w) - comp = self._cw.vreg.select_component('breadcrumbs', self._cw, self.cw_rset, view=view) - if comp and comp.propval('visible'): - comp.dispatch(w=self.w, view=view) - self.w(u' | ') - # logged user and help - #self.w(u'\n') - #comp = self._cw.vreg.select_component('loggeduserlink', self._cw, self.cw_rset) - #comp.dispatch(w=self.w) - #self.w(u' | ') - - self.w(u' | ') - helpcomp = self._cw.vreg.select_component('help', self._cw, self.cw_rset) - if helpcomp: # may not be available if Card is not defined in the schema - helpcomp.dispatch(w=self.w) - self.w(u' | ') - # lastcolumn - self.w(u'') - self.w(u' | \n') - self.w(u'