{ "info": { "author": "Pretaweb", "author_email": "support@pretaweb.com", "bugtrack_url": null, "classifiers": [ "Framework :: Plone", "Framework :: Plone :: 4.2", "Framework :: Plone :: 4.3", "Framework :: Plone :: 5.0", "Framework :: Plone :: 5.1", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": ".. contents::\n\nIntroduction\n============\n\n.. image:: https://secure.travis-ci.org/collective/collective.listingviews.png\n :target: http://travis-ci.org/collective/collective.listingviews\n\n``collective.listingviews`` allows a Plone site administrator to quickly create a new display\nview their content types, folders, collections and eea.facetnavigation. It will also let you create\ncustom portlets.\n\n.. |listingviews| image:: https://cloud.githubusercontent.com/assets/41700/5023294/b6f6e9e0-6b27-11e4-8516-2b4a50ef66c5.png\n :width: 50pt \n.. |edit listing view| image:: https://cloud.githubusercontent.com/assets/41700/5023298/bdd25150-6b27-11e4-8be8-010e3c2cc6d0.png\n :scale: 50 %\n.. |display menu| image:: https://cloud.githubusercontent.com/assets/41700/5023300/c1546ad4-6b27-11e4-844e-e3d658009731.png\n :scale: 50 %\n.. |unthemed| image:: https://cloud.githubusercontent.com/assets/41700/5023303/c5cdc2f4-6b27-11e4-9a0d-e89e5b99b71e.png\n :scale: 50 %\n.. |themed| image:: https://cloud.githubusercontent.com/assets/41700/5023306/c9e2f918-6b27-11e4-86aa-efd49d202ec8.png\n :scale: 50 %\n\n\n1. Go to Site Setup > Listing Views. |listingviews|\n2. Select the fields you want to display and give your view a name and class tag. Pick which content types this view will be \n available to. \n |edit listing view|\n4. Once you've added your view definition you can use the \"Display Menu\" or \"Listing view portlet\" to apply this view where you want. \n If you use it on a folder or\n collection it display a list items with just the fields you defined. If you use your view on a single item, it will display a list\n with a single set of fields. If you use a portlet, you can either point it to a fixed item, folder or collection, or it will display\n the content of the current context. \n |display menu| \n |unthemed| \n5. If you require further customisation: use diazo to customise the layout/html of your fields or you can \n use custom fields via \"Site setup\" if you need combine field values, format a value or access plone api's.\n |themed| \n \nFor example you could\n\n- create a news listing which displays the first sentance and publish date of each news item\n- create a footer portlet for each page which displays the last updated date of the current content\n- create a portlet which grabs a random image from a folder\n- create a listing of folders which contain pdfs of different languages and display links to each version of the pdf.\n\nThis plugin is very flexible and can be used to:\n\n- create custom views of folders or collections that include metadata and\n content from contained or matching items;\n- create custom listing portlets with additional information such as\n lead images, publication dates or authors;\n- create listing views with subqueries or python via `TAL expressions`_;\n- create additional views of non-folderish content items, showing other aspects of the\n content;\n- create portlets to display information about the current item such as last\n updated date, or even the whole content replacing plugins like ItemViewPortlet;\n- create carousel portlets which pull content or images from collections or\n folders and apply javascript to them, replacing collective.carousel are related\n plugins;\n- create custom listings for ``eea.facetednavigation``;\n\nListing Views are designed to be simple to create quickly on a Plone site\nand avoid the complexity of creating custom page templates or overridden\nviews for many common cases.\n\nView definitions are created inside the Plone Site setup by TTW developers. \nContent editors can apply the views to content items via the\n``Display Menu`` for content or in a ``Listing View Portlet`` for portlets \n(and in the future in a ``Content Listing Tile``).\n\nThe HTML markup used by the view is simple and designed to be easily adapted\nto your needs using CSS or Diazo. Each view consists of:\n\n- a definition list of fields of the target or context content item;\n- a list of definition lists of fields for each the listed items if the\n target or context is a folder, or collection;\n- unique CSS classes for the lists and each field type.\n\nBy default Fields that can make up a ListingView are :\n\n- Any Metadata fields stored in the catalog (e.g. Title, Effective Date)\n- Some Metadata fields with formatting applied (e.g. Title (Link), Effective Date (Date & Time))\n- Any custom TAL expressions\n\nPlone 4.3.5/4.3.6 issues\n========================\n\nThere is a known issue which breaks widgets when editing listing views.\nThis is due to a regression bug in z3c.form 3.2.3 which ships with Plone 4.3.5 and 4.3.6.\n\nYou will need to pin a different version of z3c.form. Add the following to versions::\n\n [versions]\n ...\n z3c.form = 3.2.4\n\n(If for some reason you need to pin an older version of z3c.form you should be fine.\nJust stay away from the 3.2.3 version)\n\nWorked Examples\n===============\n\n>>> from zope.component.hooks import getSite; plone =getSite()\n>>> from plone.uuid.interfaces import IUUID\n\nCreating a custom field\n-----------------------\n\nLet's say have a design that demands that has a folder displaying the publication date for each item.\n\nMost of this can be achieved using diazo and css however the publication date isn't in any of Plone's default listing\nviews.\nPreviously you would have to dig into Plone's code base, find it's folder template implementation and then\nuse ``jbot`` or ``ZCML`` template overrides to customise the folder listing template.\nNot only will you need to learn about TAL, python, packaging and deployment but the end result will make your site\nharder to upgrade. Any future enhancements in Plone's folder template will have to be merged back into your patched\noverriden template.\n\nInstead here is how you do it using a ListingView.\n\nFirst we need to create a custom field using TAL since we want a custom date format rather than Plones default.\nA TAL Expression like the following will work.\n\n>>> tal = \"python:item.effective.strftime('%d/%m/%Y') if item.EffectiveDate != 'None' else '' \"\n\n- Go to ``Site Setup > Listing Custom Fields > Add``\n- The ``Id`` is unique and is also used as a CSS class in the final html\n- The ``Title`` is what the editor picks from the ``Display Menu`` or in the ``ListingView Portlet``\n- Finally the TAL Expression that is evaluated when showing the field. ``item`` is the catalog brain.\n ``object`` or ``here`` is the context object. Below is the TAL we are going to use.\n\n>>> browser = layer['manager']\n>>> browser.getLink('Site Setup').click()\n>>> browser.getLink('Listing Custom Fields').click()\n>>> browser.getControl('Add').click()\n>>> browser.getControl('Id').value = \"pubdate\"\n>>> browser.getControl('Title').value = \"Local Publication Date\"\n>>> browser.getControl('TAL expression').value = tal\n>>> browser.getControl('Save').click()\n\n\nCreating a listing view\n-----------------------\n\nNow that we've created our custom field we can add a new Listing View via\n``Site Setup > Listing View > Add``.\n\n>>> browser.getLink('Site Setup').click()\n>>> browser.getLink('Listing View').click()\n>>> browser.getControl('Add').click()\n\nThere are two kinds of information a listing view display. Information about the context object called\n``Item Fields`` and information about the contents or matched items called ``Listing Fields``.\nThese fields come from either standard metadata or the custom fields we add.\n\n>>> 'Description' in browser.getControl('Title', index=1).control.displayOptions\nTrue\n\n\n#>>> print '\\n'.join( sorted(browser.getControl('Title', index=1).control.displayOptions) )\nCreation Date (Date & Time)\nCreation Date (Date)\nCreator\nDescription\nEffective Date (Date & Time)\nEffective Date (Date)\nEnd Date (Date & Time)\nEnd Date (Date)\nExpiration Date (Date & Time)\nExpiration Date (Date)\nShort Name\nShort Name (Link)\nSize\nLocal Publication Date (Custom)\nLocation\nModification Date (Date & Time)\nModification Date (Date)\nState\nStart Date (Date & Time)\nStart Date (Date)\nTags\nTitle\nTitle (Link)\nTotal number of comments\nItem Type\n...\n\nBy default the view will be enabled for standard content types. These are\n\n>>> options = browser.getControl('Page').control.displayOptions\n>>> options = [o for o in options if 'old-style' not in o]\n>>> print '\\n'.join( options )\nCollection\nComment\nEvent\nFile\nFolder\nImage\nLink\nNews Item\nPage\n\nIn this case we'll create a view called ``News with publication``.\nFor the context object we'll show\n\n - ``Title``\n\nfor each of the content items\n\n - ``Title``\n - ``Title (Link)``\n - ``Effective Date``\n - ``Local Publication Date``\n\nand finally we'll enable the view for all content types\n\n>>> browser.getControl('Id').value = \"pubnews\"\n>>> browser.getControl('Title', index=0).value = \"News with publication\"\n>>> layer.setInAndOut(browser, ['Title'], index=1)\n>>> if plone5: layer.setInAndOut(browser, ['Title', 'Title (Link)', 'EffectiveDate (Date)', 'Local Publication Date (Custom)'], index=3)\n>>> if not plone5: layer.setInAndOut(browser, ['Title', 'Title (Link)', 'Effective Date (Date)', 'Local Publication Date (Custom)'], index=3)\n>>> layer.setInAndOut(browser, browser.getControl('Page').control.displayOptions, index=0 )\n>>> browser.getControl('Add').click()\n\nWe can manage our existing listing views including a link to edit the view we just created.\n\n>>> browser.getLink('pubnews')\n\n\nUsing a listing view on a folder\n--------------------------------\n\nWe have a ``folder1`` with some pages in including a Page called ``item1``.\nUsing the ``Display > News with publication`` menu we will change the folder view to\n``News with publication`` view we created.\n\n>>> browser.getLink('folder1').click()\n>>> browser.getLink('item1')\n\n>>> browser.getLink('folder1').click()\n>>> browser.getLink('News with publication').click()\n\n\nYou will now have a listing that contains all the information you need.\nWe have\n\n- a definition for the fields of the folder (the context item)\n- an unordered list of definition lists for every item contained in the folder.\n\n - the title of ``item1``\n - a title made into a link to ``item1``\n - the ``EffectiveDate`` using Plone's default Date format\n - and finally our custom version of the effective date\n\nNote the html is in exactly the same order as we specifed in our view definition\n\n\n>>> print browser.contents\n<...\n
| \n | \n \n Published | \n \n | \n