I had a portlet which simply showed all documents of a certain type in the current folder. I needed a way to limit the portlet to show no more than 10 documents.
I knew I had to edit the tal:repeat statement to limit the results to 10 only.
Below is my original code:
<h2>Recent Items</h2>
<ul class="recentItemsListing">
<li class="recentItem"
tal:repeat="ritem view/getRecentItems">
<a tal:content="ritem/Title"
tal:attributes="href ritem/getURL"></a>
</li>
</ul>
I changed it to the following:
<h2>Recent Items</h2>
<ul class="recentItemsListing"
tal:define="restricetdRecentItems python:view.getRecentItems()[:10]">
<li class="recentItem"
tal:repeat="ritem restricetdRecentItems">
<a tal:content="ritem/Title"
tal:attributes="href ritem/getURL"></a>
</li>
</ul>
Good Luck to whoever founds this code useful.
No comments:
Post a Comment