Smart Folders and Topics

Smart Folders and Topics by David Whelan I know you’re supposed to read the manual, whatever. One of the things I love Plone for is the ability to attach metadata to an object’s properties and then get at it from other places. I’d used Topics for this purpose and was trying to figure out how to use them again. Then I read more about how Smart Folders are the new Topics.

They really seem so much easier to use, let alone having the ability to define multiple criteria and have sub-smart folders. Once I tumbled to the fact (with the help of Google and this article – which, whether a “how to” or a “tutorial” was very useful), things fell into place.

I’ve tweaked my topic results so that I can get my keywords to appear. That way, anyone who happens to find something on this site worth following up can click to see what else I’ve “tagged” with the same keywords.

I had to bring some code forward from my 2.0.5 installation, where I’d customized the topic view. In 2.5, it’s the folder_listing template. First, I added two lines to the “define” part:

  • item_subject item/Subject;
  • item_title item/Title;

Then I added this chunk to create a new “definition” to follow after the description:

<dd style=”border-top: 1px dashed #CCCCCC;”>
<span>Read more:&nbsp;&nbsp;
<a href=”#” style=”text-decoration: underline;”
tal:attributes=”href string:${item_url}/view”
tal:define=”item_title item/Title/strip”>
<span tal:replace=”item_title_or_id”>Title or id</span>
</a>
</span></dd>
<dd>Related Topics:&nbsp;
<span tal:repeat=”relatedtop item_subject”>
<a href=”#” style=”text-decoration: underline;”
tal:attributes=”href python: ‘/search?Subject=’ + relatedtop”>
<span tal:replace=”relatedtop”>Subject</span>
</a>&nbsp;
</span>
</dd>

This returns both a link to the “full” article, so that I get a blog-like effect using the Smart Folder, but also my metadata links. I suppose one could find a way to suck the “comment” information out as well, if discussion is enabled on the object.

Apologies in advance to anyone offended by the primitive or dumb nature of this code.  I remember trying to piece chunks together from other templates in 2.0.5 and can’t pretend to no more about it than I do.

Document Actions