Note that there are some explanatory texts on larger screens.

plurals
  1. POOmit site site in returned result when using getPath in Plone page templates
    primarykey
    data
    text
    <p>I have a piece of TALES for a page template in Plone which looks through the results of a collection and inserts them into a box (similar to that of a collection portlet)</p> <p>I have an issue in getting a URL from the returned items, I have been using getPath however it returns the site name, so my URLS end up being <code>http://mysite.com/ThePloneSite/folder/page</code> instead of just <code>http://mysite.com/folder/page</code>, currently my example TALES is as follows:</p> <pre><code>&lt;a tal:attributes="href string:${item/getPath}/view"&gt;Item&lt;/a&gt; </code></pre> <p>I have tried every variation I can imagine but I can't remember them all so here's a couple that don't work:</p> <p>(this returns nothing)</p> <pre><code>&lt;a tal:attributes="href item/absolute_url"&gt;Item&lt;/a&gt; </code></pre> <p>this gives me a traceback, complaining about "getpath":</p> <pre><code>&lt;a tal:attributes="python:item.getObject().absolute_url()"&gt;Item&lt;/a&gt; </code></pre> <p>The only reason the site name being in the link is annoying is that in order to access the "State" and "Display" buttons you must click "View" after originally clicking on the link</p> <p>NOTE: the last example works when you're using <code>getFolderContents</code> however I understand returning results from a collection are different.</p> <p>Any help would be greatly appreciated, thanks.</p> <p><strong>EDIT</strong> Traceback for absolute version:</p> <pre><code>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: &lt;PythonExpr alldoc.getObject().absolute_url()&gt; - Names: {'container': &lt;PloneSite at /peacehospice&gt;, 'context': &lt;ATDocument at /peacehospice/front-page&gt;, 'default': &lt;object object at 0x7fbed9313b30&gt;, 'here': &lt;ATDocument at /peacehospice/front-page&gt;, 'loop': {u'alldoc': &lt;Products.PageTemplates.Expressions.PathIterator object at 0x7fbebcd20c50&gt;}, 'nothing': None, 'options': {'args': ()}, 'repeat': &lt;Products.PageTemplates.Expressions.SafeMapping object at 0x7fbebde89680&gt;, 'request': &lt;HTTPRequest, URL=http://demo.kcsts.co.uk/front-page/home_page_view&gt;, 'root': &lt;Application at &gt;, 'template': &lt;ZopePageTemplate at /peacehospice/home_page_view used for /peacehospice/front-page&gt;, 'traverse_subpath': [], 'user': &lt;PropertiedUser 'dan'&gt;} Module Products.PageTemplates.ZRPythonExpr, line 48, in __call__ - __traceback_info__: alldoc.getObject().absolute_url() Module PythonExpr, line 1, in &lt;expression&gt; 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 </code></pre> <p>TALES for getting content of collection:</p> <pre><code>&lt;div id="all-documents" tal:define="allDocsBatch python:context.documents.alldocuments.results(b_start=b_start,b_size=10)"&gt; &lt;h3&gt;All Documents&lt;/h3&gt; &lt;div class="tabbedWrapper"&gt; &lt;div class="item" tal:repeat="alldoc allDocsBatch"&gt; &lt;p&gt; &lt;img tal:replace="structure alldoc/getIcon" /&gt; &lt;a tal:attributes="href python:alldoc.getObject().absolute_url()" tal:content="alldoc/Title" /&gt; &lt;span class="tags" tal:condition="alldoc/Subject" tal:define="alldoctag alldoc/Subject"&gt; &lt;a tal:repeat="tag alldoctag" tal:content="tag" tal:attributes="href string:${context/portal_url}/@@search?Subject:list=${tag}"/&gt; &lt;/span&gt; &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>EDIT #2</strong></p> <p>NOTE found a link <a href="http://copilotco.com/mail-archives/plone-users.2007/msg05113.html" rel="nofollow">http://copilotco.com/mail-archives/plone-users.2007/msg05113.html</a> which may help but haven't had a chance to look at it just yet.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload