[Zope] dtml-return question
Jeff K. Hoffman
jeff@goingv.com
Mon, 17 Jan 2000 12:21:39 -0500 (EST)
On Mon, 17 Jan 2000, James W. Howe wrote:
> I want to add a DTMLMethod to a folder which will be used to return a
> subset of the items in the folder. I've written a method called
> allNewsArticles which looks like this:
>
> <dtml-return "objectValues('NewsArticle')">
>
> I have a method in another folder which references the result of this
> method and it looks like this:
>
> <dtml-in allNewsArticles>
> <... do stuff here...>
> </dtml-in>
>
> When I execute the DTMLMethod containing the code above, I get no output
> for the dtml-in. However, if I do the following in the method above
> (instead of using the allNewsArticles method), I do get output:
>
> <dtml-in "PARENTS[1].objectValues('NewsArticle')">
> <... do stuff here ...>
> </dtml-in>
>
> I don't want to use the PARENTS approach because I don't know for sure that
> the immediate predecessor will have the news articles. Is there a way for
> a DTMLMethod to return a collection of items which are usable by a
> dtml-in tag?
I think the problem is coming from the fact that DTML Methods are acquired
differently than, say, a DTML Document or an Image. When a DTML Document
is acquired, for instance, any DTML inside of it is executed in the
context of the document (wherever it is located in the OFS.) However, when
a DTML Method is acquired, any DTML it contains is executed in the context
of the acquiring object.
i.e.:
- /
- standard_html_header (Method)
- standard_html_footer (Method)
- doc1 (Document)
- meth1
- test/
- standard_html_header
The URL http://myzope.com/doc1 will render the doc1 Document with the
standard_html_header in the root. The URL http://myzope.com/meth1 does
the same. In addition, the URL http://myzope.com/test/meth1 will
show the standard_html_folder from the test folder, as expected. However,
the URL http://myzope.com/test/doc1 does not render the doc1 Document with
the standard_html_header in test, as you might expect; the URL
http://myzope.com/test/doc1 ends up displaying the standard_html_header in
the root folder.
I think your DTML Method (allNewsArticles) is getting acquired into the
folder that is calling it, which probably contains no news items. Without
seeing more of your site structure, I, unfortunately, can't suggest how to
fix it.
That's my guess, anyway.
> James W. Howe
--Jeff
---
Jeff K. Hoffman 704.849.0731 x108
Chief Technology Officer mailto:jeff@goingv.com
Going Virtual, L.L.C. http://www.goingv.com/