Plone 4: How to retrieve the item category/tags/keywords inside a page template
I am working on a custom portlet and I'm trying to determine the best way to know whether a content item returned by a collection has a particular tag/keyword. Do the collection results expose this data? If so, how do I access that from my portal's page template. If not, what would I have to customize in order to have it be exposed? I want to be able to add a particular css class to items with a certain keyword/tag.
In other words:
Is there anything that would work like item.getSubject()
which would return all keywords, or item.hasSubject("foo")
?
Update: @Giacomo - I had tried that, but failed to realize that Subject was a tuple. I was able to achieve the desired result in the template with something like:
<dd class="portletItem"
tal:define="featured python:' featured' if 'feature' in obj.Subject else '';"
tal:attributes="class python:oddrow and 'portletItem even'+ featured or 'portletItem odd' + featured"&开发者_Go百科gt;
where feature is the Tag I enter on the content items, and .featured is a css class added to the portlet item. I am new to Plone. Is there comprehensive online documentation where you can search the source tree (for classes, methods, etc) or am I stuck with using grep to search for things?
you can access collections results and they are just catalog brains, for example:
for i in context.queryCatalog():
print i.Subject
if your template is not directly registered on collections you just need to replace context
with the actual collection name
精彩评论