[Zope] objectItems() question
Casey Duncan
cduncan@kaivo.com
Mon, 16 Apr 2001 09:32:25 -0600
Ben.Peter@t-online.de wrote:
>
> Hello all,
>
> I am utterly confused:
>
> The following piece of dtml in standard_html_header
>
> <dtml-in "objectItems()">
> <a href="<dtml-var absolute_url>"><dtml-var title></a>
> <dtml-unless sequence-end><br>
> </dtml-unless>
> <dtml-else>No items.
> </dtml-in>
>
> will yield a complete list of objects in the current container if there is
> a DTML Method 'index_html' available. If that is not the case, it will
> print 'No items.', even if there is a DTML Document index_html and any
> number of other Items, like folders.
>
> Is this intentional or (which I believe it'll turn out to be) am I blind
> again?
>
> Thanks for your help,
> Ben
>
> --
> Ben Peter - Feldstrasse 8 - 35091 Coelbe
> Ben.Peter@t-online.de
> ph: (+49) 6421 983520
>
DTML Documents subclass from SimpleItem.Item which purposely masks
objectItems, et al because they are not containers. To get your code to
work properly, you must first check to see whether the current context
is a folder or not (which it will be if the url points to a DTML
Method). You can do this by checking for the attribute
"isPrincipiaFolderish" which all folderish objects will have set to
true:
<dtml-if name="isPrincipiaFolderish">
<dtml-call expr="REQUEST.set(folder, this())">
<dtml-else>
<dtml-call expr="REQUEST.set(folder, aq_parent)">
</dtml-if>
<dtml-in expr="folder.objectItems()">
...
</dtml-in>
hth,
--
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>