Skip to main content

A collection portlet product which supports multiple views

Project description

Introduction

The collectionmultiview portlet is a collection portlet which supports multiple view modes. It inherits the built-in plone.portlet.collection and extend it with view adapters support.

Writing additional views

Creating an additional view is as simple as writing a class which inherits from BaseRenderer, and register it as a named adapter

Sample code:

from collective.portlet.collectionmultiview import BaseRenderer
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile

class MyCustomRenderer(BaseRenderer):
    title = 'My Custom Renderer'
    template = ViewPageTemplateFile('path/to/template.pt')

ZCML:

<configure
   xmlns="http://namespaces.zope.org/zope">

   <adapter name="mycustomrenderer"
       factory=".package.MyCustomRenderer"/>

</configure>

Extending portlet schema

You can also extend the portlet schema with additional fields by setting the ‘schema’ attribute in the renderer class.

Sample code:

from collective.portlet.collectionmultiview import BaseRenderer
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile

from zope import schema
from zope.interface import Interface
from plone.app.form.widgets.wysiwygwidget import WYSIWYGWidget

class IExtraFields(Interface):
    my_extra_field = schema.Text(title=u'Extra field')

class MyCustomRenderer(BaseRenderer):
    title = 'My Custom Renderer'

    schema = IExtraFields
    template = ViewPageTemplateFile('path/to/template.pt')


    #optional
    custom_widgets = {
        'my_extra_field': WYSIWYGWidget
    }

Changelog

2.1.0 (2012-11-06)

  • Added support for new style collection [kagesenshi]

2.0.2 (2012-03-26)

  • Added way to assign custom widget [kagesenshi]

2.0.1 (2012-03-20)

  • Fixed problem with installation of 2.0 due to missing README.rst [jone]

2.0 (2012-03-20)

  • Added mechanism for additional views to extend the portlet schema [kagesenshi]

  • Massive code cleanups [kagesenshi]

  • CREDIT: changes above funded by cis-india.org

1.1.2 (2011-06-06)

  • Plone 4.1 compat [aclark]

1.1.1 (2011-03-31)

  • bugfix release. fixed a bug with the renderer selector using title as value

    instead of id

1.1 (2011-03-27)

  • Plone4 compatibility

  • Renderers now may have a human readable __name__

  • Removed GalleryRenderer as it is broken anyway

  • Hide unnecessary fields from the base Plone collection portlet.

1.0 (2010-12-19)

  • fix permission used for portlet [vangheem]

0.1 (2009-12-31)

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

File details

Details for the file collective.portlet.collectionmultiview-2.1.0.zip.

File metadata

File hashes

Hashes for collective.portlet.collectionmultiview-2.1.0.zip
Algorithm Hash digest
SHA256 fc6690baccb658673a929fe5ded2dcf6dcddae3432e1c8897ae1ad16b6153868
MD5 2288b63c11cafabe8d46c6a7def13414
BLAKE2b-256 4d2606d146c072f904b50c12d2184b72b22b2beee432dff7e02fe97dd270880e

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page