Behaviors
手動啟用或停用的方式,是到 @@dexterity-types 選擇型別,再由 Behaviors 頁籤裡勾選,儲存後就生效。以 Versioning 為例,啟用後會出現在表單最下方。
plone.app.contenttypes 提供 Lead Image, Table of Contents, Collection, RichText 功能。
collective.instancebehavior 利用 updateFields 技巧,可以針對特定型別啟用功能。
https://github.com/collective/collective.behavior.banner/issues/5#issuecomment-160594587
RichText
from plone.app.textfield.interfaces import ITransformer transformer = ITransformer(context) transformedValue = transformer(context.body, 'text/plain')
plone.app.contenttypes RichText 檢查是否安裝的判斷範例
import pkg_resources try: pkg_resources.get_distribution('plone.app.textfield') from plone.app.textfield.interfaces import IRichTextValue except (pkg_resources.DistributionNotFound, ImportError): HAS_PLONE_APP_TEXTFIELD = False else: HAS_PLONE_APP_TEXTFIELD = True
Could not adapt plone.dexterity.content.Container to interfaces.IPrimaryFieldInfo: Name from File Name
Schema 資料的儲存方式有 Annotation 和 Attribute 兩種。
應用情境 建立和註冊: collective.gtags 範例
Dexterity IRichText Behavior field is not searchable
Reference
Back References with z3c RelationField getBackReferences
Extend INameFromTitle: computed field kbat.content example
Supposed behaviour of the "visible ids" setting: automatic add-redirect-if-id-changed magic
collective.behavior.banner: Allow Video
Lead Image Behavior 成為 plone.app.contenttypes 內建功能 Archetypes NewsItem Image
Canoncial Way to Retrieve IntID of Content Object based on Dexterity
Should copied objects use INameChooser? 複製貼上
Add Keywords to SearchableText
Related Items Behavior: 使用 plone.app.relationfield demo.py vocabulary='plone.app.vocabularies.Catalog' eea.facetednavigation
plone.app.layout/viewlets/content.py class ContentRelatedItems(ViewletBase) document_relateditems.pt
Event
檔案在 plone.app.event/dx/behaviors.py
IEventBasic 欄位是 start, end, whole_day, open_end, timezone 還有 validate_start_end
IEventRecurrence 欄位是 recurrence
IEventLocation 欄位是 location
IEventAttendees 欄位是 attendees
IEventContact 欄位是 contact_name, contact_email, contact_phone, event_url
Navigation
Navigation Root: Microsites example: telesur.specialreport
Exclude From Navigation 預設值由 ContextAware Default Factory 取得
<adapter for="*" factory=".exclfromnav.default_exclude_false" />
Behavior 不能被套用在 Archetypes 裡,但可以自行撰寫 Adapter 納入功能: collective.workspace
讓 News Item 變成目錄式 Folderish collective.folderishtypes folderish collection PLIP 20144: Folderish Types plone.app.layoutpage 在 Dexterity 定義裡使用 Container 每次編修大約會讓 ZODB 增加 100~200 bytes 資料量, modify BTreeFolder2 to create _tree lazily rather than using __getstate__.
Versioning
表單下方通常會看到 Change Note 欄位,預設是由 Versioning 控制,底層程式是由 CMFEditions 負責。
Name Chooser
plone.app.contentrules/namechooser.py
WARNING plone.behavior Specifying 'for' in behavior 'Multilingual Support' if no 'factory' is given has no effect and is superfluous.
ThumbIcon Handling
plone.app.contenttypes/behaviors/thumb_icon.py
collective.geolocationbehavior
Specific Interface Registry 卻沒有限制的效果
WARNING plone.behavior Specifing 'for' in behavior 'xxx' if no 'factory' is given has no effect and is superfluous. 把 for="plone.dexterity.interfaces.IDexterityContent" 移除就能解決
collective.behavior.amp AMP Project
Permission
Read for Fields, checking for workflow states