Ticket #1025 (assigned defect)

Opened 14 years ago

Last modified 10 years ago

CellBlock should not use tables called by tableless pages

Reported by: ogrisel Owned by: jmorliaguet
Priority: P2 Milestone: CPS 3.4.10
Component: CPSSkins Version: TRUNK
Severity: normal Keywords:
Cc:

Description

CellBlock? lacks a tableless render method. As it is very similar to page block, the following change seems to work but is ugly since it's mostly a copy/paste of the PageBlock? method. Maybe some refactoring is neeeded. Or is it better to use a skin script/template?

Index: CellBlock.py
===================================================================
--- CellBlock.py        (révision 28406)
+++ CellBlock.py        (copie de travail)
@@ -194,7 +194,13 @@
     security.declarePublic('render')
     def render(self, shield=0, **kw):
         """Render the templet."""
+        layout_style = kw.get('layout_style')
+        if layout_style is None:
+            container = self.getContainer()
+            kw['layout_style'] = container.getCSSLayoutStyle()

+        kw['maxcols'] = self.maxcols
+
         return self.render_skin(shield=shield, **kw)

     security.declarePublic('render_skin')
@@ -207,8 +213,68 @@
         # text mode
         if textonly:
             return self.cpsskins_cellblock_textonly(**kw)
+        if kw.get('tableless'):
+            return self._renderDiv(**kw)
         return self.cpsskins_cellblock(**kw)

+    security.declarePrivate('_renderDiv')
+    def _renderDiv(self, maxcols=0, **kw):
+        """Render the page block using a <div> tag
+        """
+        rendered = []
+        main_tag = []
+        main_tag.append('class="%s"' % self.getCSSClass(level=2))
+        main_tag.append('style="%s"' % self.getCSSLayoutStyle())
+        rendered_append = rendered.append
+        rendered_append('<div %s>' % " ".join(main_tag))
+
+        more_than_one_column = maxcols > 1
+        objects = self.getObjects(**kw)
+
+        for x_pos in range(maxcols):
+            if objects.has_key(x_pos):
+                objects_in_xpos = objects[x_pos]
+            else:
+                continue
+            cell_tag = []
+            cellsize = objects_in_xpos['cellsizer']
+            if more_than_one_column:
+                style_tag = ['float:left', 'overflow-x:hidden']
+            else:
+                style_tag = []
+            if cellsize:
+                style_tag.append(cellsize.getCSSLayoutStyle())
+            cell_tag.append('style="%s"' % ';'.join(style_tag))
+            rendered_append('<div %s>' % " ".join(cell_tag))
+            contents_in_xpos = objects_in_xpos['contents']
+            for content in contents_in_xpos:
+                margin_style = content.getCSSMarginStyle()
+                if margin_style:
+                    rendered_append('<div style="%s">' % margin_style)
+                layout_style = content.getCSSLayoutStyle()
+                area_class = content.getCSSClass(level=2)
+                div_tag = []
+                if layout_style:
+                    div_tag.append('style="%s"' % layout_style)
+                if area_class:
+                    div_tag.append('class="%s"' % area_class)
+                rendered.extend([
+                    '<div %s>' % " ".join(div_tag),
+                    content.render_cache(**kw),
+                    '</div>'])
+                if margin_style:
+                    rendered_append('</div>')
+            if not contents_in_xpos:
+                rendered_append('<div>&nbsp;</div>')
+            rendered_append('</div>')
+        if more_than_one_column:
+            rendered_append(
+                '<br style="clear:left"/></div><div style="clear:left"></div>')+        else:
+            rendered_append('</div>')
+        return ''.join(rendered)
+
+
     security.declarePublic('render_cache')
     def render_cache(self, **kw):
         """Renders the cached version of the templet."""

Change History

comment:1 Changed 14 years ago by jmorliaguet

  • Status changed from new to assigned

in the zope3 version there is a widget that takes care of that. In the present case, _renderDiv could be moved to a util.py method.

comment:2 Changed 14 years ago by ebarroca

  • Milestone changed from CPS 3.4.0 to CPS 3.4.1

comment:3 Changed 14 years ago by sfermigier

  • Milestone changed from CPS 3.4.1 to CPS 3.4.2

comment:4 Changed 10 years ago by gracinet

  • Milestone changed from CPS 3.5.0 to CPS 3.4.10

The default theme system in trunk is CPSDesignerThemes now

Note: See TracTickets for help on using tickets.