Inline list iteration? (over Tags)

Is there a way to do Zope like inline iteration through lists, etc, with Tags (Subjects) that wont break things? I could probably do this with a collection if I could nest it in a larger iteration through higher level tags. I used to do this with Zope and DTML and it was effortless, I am finding myself kind of missing that flexibility. Can I have my cake inline and eat it too with Plone?

1 Like

What do you mean with inline iteration? In which context?

What is that?

Can you give a concrete example what you try to achieve?

What is your problem: getting the list or iterating over it? With respect to the iteration, Plone should be able to do it the same way as Zope. Getting a list highly depends on which list you want to get. "Tags" are likely indexed and you might be able to get them from the corresponding index.

Dieter, yes, I would like to be able to generate very compact semi tabular displays of my content like the preview window in Collections that includes tags. When a page has tags the default tag links typically render at the bottom. My real problem is that although Ive used plone fairly casually several times, the defaults have been enough for me up until now so I am really diving more deeply now for the first time. Actually, Dieter, a publication you wrote many years ago was really key to my getting a much better understanding of Zope than I had previously.

What I was getting at is that Plone page layout is much more rigid, usually that is good but in my case the main content window needs to be able to have embedded list content with tags in some instances, I would like to be able to embed some logic. This is very simple stuff. I just need to familiarize myself better with plone - actually, going a bit farther back, ZPT.

in the way I was with Zope (DTML) .

I suppose if I am really desperate to do something I can mix in some Zope content. (Taking care that the security permissions are correct) But I would really like to do it the right way, not some ugly hack.

The tags of course are

(KeywordIndex) portal_catalog/Indexes/Subject

Dieter, I think you were also the author of DocBrowserTab ?
:slight_smile:

You can use DTML with Plone - even though in Plone page templates are typically used to generate HTML.

With DTML, the "command"s are carried by elements - you would use the element dtml-in for an iteration; with page templates, the "command"s are carried by attributes- you would use the attribute tal:repeat for an iteration. Page templates are much easier than DTML as there are far fewer commands and most can be combined in a natural way. Have a look at the ZPT chapter in the "Zope Book"; you will see, it is not difficult.

A modern approach is to separate logic (implemented in Python) and presentation (often implemented with a page template) by employing a so called "view". A view typically consists of a Python class instance (for the logic) and a template (for the presentation). With such an architecture, a list display could look like <div tal:content="structure view/my_list_display" />. In this piece of code, view references the class instance; my_list_display is a method of this class and contains the logic to fetch the list and prepare its display. Look at the Plone manual for a more in-depth introduction to views.

I am the author of DocFinder. Someone else has made it available via a tab (creating DocFinderTab) - drastically facilitating its use.

Can you draw what you want to do ( I can not figure out if you want some kind of listing, sorted on tags, a table where tags are a column, or a way to filter on tags (tags=Subject)

Would it be an idea to use Diazo for this rather than solving it in your TAL template?

Basically, I would like to make a simple portlet or viewlet that displays all the tags.

in your view.py file you put something like this:

def get_subsjects(self):
    catalog = self.context.portal_catalog
    return catalog.uniqueValuesFor('Subject')

In your browser.pt you put something like this

<div tal:repeat="subject view/get_subjects">
     ${subject}
</div>
1 Like

Using the classic portlet, right? And the generic "custom" folder so it doesnt get stomped on?

I would not recommend that approach (especially since I have never made portlets that way).

I would make a new portlet in my theme (or some add on).
You could also do this with themefragments and /or diazo (especially if you want it 'as a viewlet'.

PS: Can someone who know explain how to make a portlet with bob templates (if it is possible)

Yes, thank you!!
I was just looking at the themes and their overrides, just looking at the code, that makes it much clearer.

By "viewlet" I meant simply as a content item that occupies the main central area on the page. Thats probably what you mean too.

This seems like the best way to do these kinds of things so they dont get in the way of something else.