Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Tips / Useful Variables

Useful Variables

Plone 4.3.x 使用下列設定值:

portal_state context/@@plone_portal_state;
context_state context/@@plone_context_state;
plone_view context/@@plone;
lang portal_state/language;
view nocall:view | nocall: plone_view;
dummy python: plone_view.mark_view(view);
portal_url portal_state/portal_url;
checkPermission nocall: context/portal_membership/checkPermission;
site_properties nocall: context/portal_properties/site_properties;
ajax_load request/ajax_load | nothing;
ajax_include_head request/ajax_include_head | nothing;
dummy python:request.RESPONSE.setHeader('X-UA-Compatible', 'IE=edge,chrome=1');

python:plone_view.patterns_settings()

View and Context Utilities (Helpers)

Helper Views and Tools 提到 plone.app.layout.globals.interfaces 模組裡,找得到 Helper 定義。

IContextState
  current_page_url current_base_url
tal:condition="python:context.restrictedTraverse('@@plone_context_state').canonical_object_url().split('/')[-1] == 'zh'"

canonical object vs default page object Canonical Link Element

context_state = getMultiAdapter((context, request), name=u'plone_context_state')
canonical_object = context_state.canonical_object()
canonical_url_path = canonical_object.absolute_url_path()

使用 restrictedTraverse() 存取目錄內容

portal_url site root

<a href="#"
 tal:attributes="href string:${portal_url}/mylink">My Link</a>

navigation_root_url vs portal_url http://plone.org/documentation/manual/theme-reference/page/otherinfo

portal_url = getToolByName(context, 'portal_url')()
print portal_url
'mysite'

Plone5 Compatible example - plone-legacy-compiled.js: Uncaught ReferenceError: portal_url is not defined: uwosh.pfg.d2c

JavaScript

get variables from javascript

Upgrade

http://plone.293351.n2.nabble.com/Upgrade-to-Plone-4-td4758292.html

http://plone.293351.n2.nabble.com/Plone-4-refuses-to-start-with-Plone-3-data-fs-td4167400.html

要測試 portal_catalog 是否會出現錯誤

要測試 file, image 的 blob 是否正常

getBody (This object from the PluginIndexes products is broken!) getExcerpt getExtend getSubtitle