我在 Plone 中有一个页面模板的 TALES,它查看集合的结果并将它们插入到一个框中(类似于集合 portlet)
我在从返回的项目中获取 URL 时遇到问题,我一直在使用 getPath 但是它返回站点名称,所以我的 URLS 最终http://mysite.com/ThePloneSite/folder/page
不是 just http://mysite.com/folder/page
,目前我的示例 TALES 如下:
<a tal:attributes="href string:${item/getPath}/view">Item</a>
我已经尝试了所有我能想象到的变化,但我不记得它们了,所以这里有几个不起作用:
(这不返回任何内容)
<a tal:attributes="href item/absolute_url">Item</a>
这给了我一个回溯,抱怨“getpath”:
<a tal:attributes="python:item.getObject().absolute_url()">Item</a>
链接中的站点名称令人讨厌的唯一原因是,为了访问“状态”和“显示”按钮,您必须在最初单击链接后单击“查看”
注意:最后一个示例在您使用时有效,getFolderContents
但是我理解从集合返回的结果是不同的。
任何帮助将不胜感激,谢谢。
编辑绝对版本的回溯:
Traceback (innermost last):
Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module Shared.DC.Scripts.Bindings, line 322, in __call__
Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
Module Products.PageTemplates.ZopePageTemplate, line 334, in _exec
Module Products.PageTemplates.ZopePageTemplate, line 431, in pt_render
Module Products.PageTemplates.PageTemplate, line 79, in pt_render
Module zope.pagetemplate.pagetemplate, line 113, in pt_render
Module zope.tal.talinterpreter, line 271, in __call__
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 888, in do_useMacro
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 852, in do_condition
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 954, in do_defineSlot
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 852, in do_condition
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 946, in do_defineSlot
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 821, in do_loop_tal
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 405, in do_startTag
Module zope.tal.talinterpreter, line 482, in attrAction_tal
Module Products.PageTemplates.Expressions, line 225, in evaluateText
Module zope.tales.tales, line 696, in evaluate
- URL: /peacehospice/portal_skins/custom/home_page_view
- Line 200, Column 12
- Expression: <PythonExpr alldoc.getObject().absolute_url()>
- Names:
{'container': <PloneSite at /peacehospice>,
'context': <ATDocument at /peacehospice/front-page>,
'default': <object object at 0x7fbed9313b30>,
'here': <ATDocument at /peacehospice/front-page>,
'loop': {u'alldoc': <Products.PageTemplates.Expressions.PathIterator object at 0x7fbebcd20c50>},
'nothing': None,
'options': {'args': ()},
'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x7fbebde89680>,
'request': <HTTPRequest, URL=http://demo.kcsts.co.uk/front-page/home_page_view>,
'root': <Application at >,
'template': <ZopePageTemplate at /peacehospice/home_page_view used for /peacehospice/front-page>,
'traverse_subpath': [],
'user': <PropertiedUser 'dan'>}
Module Products.PageTemplates.ZRPythonExpr, line 48, in __call__
- __traceback_info__: alldoc.getObject().absolute_url()
Module PythonExpr, line 1, in <expression>
Module AccessControl.ImplPython, line 716, in guarded_getattr
Module AccessControl.ImplPython, line 658, in aq_validate
Module AccessControl.ImplPython, line 552, in validate
Module AccessControl.ImplPython, line 322, in validate
Module AccessControl.ImplPython, line 749, in raiseVerbose
Module AccessControl.ImplPython, line 726, in item_repr
Module plone.app.contentlisting.catalog, line 29, in __repr__
Module plone.app.contentlisting.catalog, line 74, in getPath
Module Products.ZCatalog.CatalogBrains, line 51, in getPath
AttributeError: getpath
获取收藏内容的故事:
<div id="all-documents" tal:define="allDocsBatch python:context.documents.alldocuments.results(b_start=b_start,b_size=10)">
<h3>All Documents</h3>
<div class="tabbedWrapper">
<div class="item" tal:repeat="alldoc allDocsBatch">
<p>
<img tal:replace="structure alldoc/getIcon" />
<a tal:attributes="href python:alldoc.getObject().absolute_url()" tal:content="alldoc/Title" />
<span class="tags" tal:condition="alldoc/Subject" tal:define="alldoctag alldoc/Subject">
<a tal:repeat="tag alldoctag" tal:content="tag"
tal:attributes="href string:${context/portal_url}/@@search?Subject:list=${tag}"/>
</span>
</p>
</div>
</div>
</div>
编辑#2
注意找到了一个链接http://copilotco.com/mail-archives/plone-users.2007/msg05113.html这可能会有所帮助,但还没有机会查看它。