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? Thanks. James W. Howe AppNet Inc. 650 Avis Dr. Suite 100 mailto:james.howe@appnet.com Ann Arbor, MI 48108 http://www.appnet.com
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/
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>
There... since you call allNewsArticles in another folder, it tries to find the NewsArticles under this 'other folder'. I think what you need is this (untested): <dtml-with "/path/to/folder_with_newsitems"> <dtml-in "objectValues('NewsArticle')"> <.. do stuff here ...> </dtml-in> </dtml-with> Hope this helps. ~Shalabh --------------------------------------------------------------- "We are all in the gutter, but some of us are looking at the stars" -Oscar Wilde ---------------------------------------------------------------
Shalabh Chaturvedi wrote: [snip]
I think what you need is this (untested):
<dtml-with "/path/to/folder_with_newsitems">
Common mistake, but this can't work, you need a Python expression between "..", not an URL path, so: <dtml-with "PARENTS[-1].path.to.folder_with_newsitems"> Or something like that. Regards, Martijn
participants (4)
-
James W. Howe -
Jeff K. Hoffman -
Martijn Faassen -
Shalabh Chaturvedi