问题
I am creating a secondary navigation bar on a Plone 4 site which looks at the contents of sub folders.
My site structure looks like the following:
Plone Site
|
|--Folder1
|--PageA
|--PageB
|--Folder2
|--PageC
|--PageD
My TALES is as follows (I appreciate that this is probably not the most elegant code):
<tal:subsections tal:define="isDocument python:getattr(context,'portal_type','') == 'Document';
isFolder python:getattr(context,'portal_type','') == 'Folder';
subitemsDocument python:context.aq_parent.aq_inner.getFolderContents(contentFilter={'portal_type':'Document'});
subitemsFolder python:context.getFolderContents(contentFilter={'portal_type':'Document'});
root_url context/portal_url;
front_url string:${root_url}/front-page;
current_url context/absolute_url;" tal:condition="context/portal_membership/isAnonymousUser">
<ul id="subnav" tal:condition="isFolder">
<tal:subtabsfolder tal:repeat="subitem subitemsFolder">
<li tal:define="item_url subitem/getURL"
tal:attributes="class python:current_url==item_url and 'selected' or 'plain'">
<a tal:attributes="href subitem/getURL" tal:content="subitem/Title"/>
</li>
</tal:subtabsfolder>
</ul>
<ul id="subnav" tal:condition="isDocument">
<tal:subtabsdocument tal:repeat="subitem subitemsDocument">
<li tal:define="item_url subitem/getURL"
tal:attributes="class python:current_url==item_url and 'selected' or 'plain'">
<a tal:attributes="href subitem/getURL" tal:content="subitem/Title"
tal:condition="python:front_url != current_url"/>
</li>
</tal:subtabsdocument>
</ul>
</tal:subsections>
Everything is working well, my only problem is that I do not have a way of telling the template to ignore items that have been used as the default view of a container.
Is there a TALES condition I can use to accomplish this?
Any help is greatly appreciated, thanks.
回答1:
You can simply use Plone's context-utilities for that, like this:
tal:condition="not: subitem/@@plone_context_state/is_default_page
In case you're courious Six Feet Up provides a nice quick-sheet, for more variable-references as a PDF.
By the way: I'd apply the condition to the list-element instead of the link element, to not render an unnecessary empty list-element.
来源:https://stackoverflow.com/questions/17925001/hide-default-view-from-getfoldercontents-results-with-tales-on-plone-4