Plone: View einem Contenttype zuordnen
Registriert ein View für einen bestimmten Contenttype.
browser/configure.zcml
+ <browser:menuItem
+ for="..interfaces.artikel.IArtikel"
+ menu="plone_displayviews"
+ title="Artikel Ansicht"
+ action="@@ansicht_view"
+ description="Artikel Ansicht"
+ />
Methode 1 - Zuordnung für ein eigenen Artikeltyp
Diese schnelle Möglichkeit ist sinnvoll für Ansichten die einem eigenen Artikeltyp (folderish) zugeordnet wird.
profiles/default/types/Artikel.xml
- <property name="default_view">base_view</property>
+ <property name="default_view">ansicht_view</property>
<property name="view_methods">
- <element value="base_view" />
+ <element value="ansicht_view" />
</property>
Methode 2 - Zuordnung für ein bestehenden Artikeltyp (z.B. Folder)
Diese Methode sollte verwendet werden wenn eine Ansicht einem vorhandenem Artikeltyp zugeordnet wird
setuphandlers.py
from Products.CMFCore.utils import getToolByName
from Products.CMFEditions.setuphandlers import DEFAULT_POLICIES
def setupView(portal, out):
""" Add plone-views to folder types """
typesTool = getToolByName(portal, 'portal_types')
# install view for folders
typefolder = typesTool['Folder']
viewlist = typefolder.getProperty('view_methods', d=None)
if 'ansicht_view' not in viewlist:
viewlist = viewlist + ('ansicht_view',)
typefolder.manage_changeProperties(view_methods = viewlist)
out.append("Successfully installed my.product ansicht_view in folder")
typefolder = typesTool['Large Plone Folder']
viewlist = typefolder.getProperty('view_methods', d=None)
if 'ansicht_view' not in viewlist:
viewlist = viewlist + ('ansicht_view',)
typefolder.manage_changeProperties(view_methods = viewlist)
out.append("Successfully installed my.product ansicht_view in largefolder")
def importVarious(context):
"""Miscellanous steps import handle """
# Ordinarily, GenericSetup handlers check for the existence of XML files.
# Here, we are not parsing an XML file, but we use this text file as a
# flag to check that we actually meant for this import step to be run.
# The file is found in profiles/default.
if context.readDataFile('my.product_various.txt') is None:
return
# Add additional setup code here
out = []
portal = context.getSite()
setupView(portal, out)
logger = context.getLogger("my.product")
profiles/default/import_steps.xml
<?xml version="1.0"?>
<import-steps>
<import-step id="my-product-various" version="2011-06-28"
handler="my.product.setuphandlers.importVarious"
title="my.product setup">
my.product setup
</import-step>
</import-steps>
profiles/default/my.product_various.txt
# This file is used as a marker in setuphandlers.py.