Dinan Informatica

Personal tools
You are here: Home Apuntes Theming Plone 4 con Deco.gs (utilizando sunburst)
Document Actions

Theming Plone 4 con Deco.gs (utilizando sunburst)

http://noenieto.com/blog/theming-plone-4

Ejemplo cambiando la posicion de las columnas para que salgan a la derecha:

  • En src:
../bin/paster create -t plone3_theme
  • Cambiar "Plone Default" por "Sunburst Theme" en profiles/default/skins.xml
  • Añadir el tema al buildout (eggs y develop) y ./bin/buildout
  • En browser/interfaces.py añadir:
class IDinanView(Interface):
    """ """
    def getColumnsClass():
        """ Returns the CSS class based on columns presence. """
  • En browser crear nuevo archivo dinanview.py (para la disposicion de las columnas usando Deco):
from zope.interface import implements
from zope.component import getMultiAdapter

from Acquisition import aq_inner
from Products.Five import BrowserView

from dinan.theme.browser.interfaces import IDinanView

_marker = []

class DinanView(BrowserView):
    implements(IDinanView)
   
    def getColumnsClass(self, view=None):
        """ Determine whether a column should be shown. The left column is called
        plone.leftcolumn; the right column is called plone.rightcolumn.
        """
        context = aq_inner(self.context)
        plone_view = getMultiAdapter((context, self.request), name=u'plone')
        sl = plone_view.have_portlets('plone.leftcolumn', view=view);
        sr = plone_view.have_portlets('plone.rightcolumn', view=view);
        portal_state = getMultiAdapter((context, self.request), name=u'plone_portal_state')
       
        if not sl and not sr:
            # we dont't have columns, thus content takes the whole width
            return "cell width-full position-0"
        elif sl and sr:
            # In case we have both columns, content takes 50% of the whole
            # width and the rest 50% is spread between the columns
            return "cell width-1:2 position-0"
        elif (sr and not sl) and (portal_state.is_rtl()):
            # We have right column and we are in RTL language
            return "cell width-3:4 position-1:4"
            #return "cell width-3:4 position-0"
        elif (sr and not sl) and (not portal_state.is_rtl()):
            # We have right column and we are NOT in RTL language
            return "cell width-3:4 position-0"
        elif (sl and not sr) and (portal_state.is_rtl()):
            # We have left column and we are in RTL language
            return "cell width-3:4 position-1:4"
            #return "cell width-3:4 position-0"
        elif (sl and not sr) and (not portal_state.is_rtl()):
            # We have left column and we are NOT in RTL language
            return "cell width-3:4 position-0"
  • En browser/configure.zcml añadir:
  <!-- Dinan special view -->
  <browser:page
      for="*"
      name="dinanview"
      class=".dinanview.DinanView"
      permission="zope.Public"
      allowed_interface=".interfaces.IDinanView"
      />
  • En dinan_theme_custom_templates copiar el main_template.pt de sunburst y modificar
sunburst_view python:context.restrictedTraverse('@@sunburstview')"

por

sunburst_view python:context.restrictedTraverse('@@dinanview')"

y sustituir la parte de la columna de la izquierda por

<div id="portal-column-one" 
            class="cell width-1:4 position-3:4"
            metal:define-slot="column_one_slot"
            tal:condition="python:sl and not sr"
            tal:attributes="class python:isRTL and 'cell width-1:4 position-0' or 'cell width-1:4 position-3:4'">
            <metal:portlets define-slot="portlets_one_slot">
                <tal:block replace="structure provider:plone.leftcolumn" />
            </metal:portlets>
        </div>
        <div id="portal-column-one"
            class="cell width-1:4 position-1:2"
            metal:define-slot="column_one_slot"
            tal:condition="python:sl and sr"
            tal:attributes="class python:isRTL and 'cell width-1:4 position-1:2' or 'cell width-1:4 position-1:2'">
            <metal:portlets define-slot="portlets_one_slot">
                <tal:block replace="structure provider:plone.leftcolumn" />
            </metal:portlets>
        </div>