[Zope] shortcutting the tree tag

Martin Dougiamas martin@complex.curtin.edu.au
Wed, 28 Apr 1999 22:53:40 +0800 (WST)


Hi John,

The way I do this is to set up an external method containing:

def publicObjects(self):
    "return only public sub-documents and folders"
    result=[]
    for object in self.objectValues(['Folder']):
        if hasattr(object,'hidden') and not object.hidden:
            result.append(object)
    return result

and then make your tree tag use this method with:

<!--#tree branches="publicObjects"-->

    [...]

<!--#/tree-->


Hope that helps,
Martin




John Eikenberry wrote:
> 
> 
> I've just started messing around with the tree tag. I'm looking for a way
> to keep it from recursing through subdiretcories. Ie...
> 
> I have call the tree tag like so...
> 
> <!--#tree expr="PARENTS[-1]" branches_expr="objectValues(['Folder'])"-->
> 	<!--#unless hidden-->
> 		<A HREF="<!--#var tree-item-url-->">
> 		<!--#var title_or_id-->
> 		</A>
> 	<!--#/unless-->
> <!--#/tree-->
> 
> And have a basic folder structure like so...
> 
> +foo
>     +bar
>         -file
> 
> I have the 'hidden' property set on 'foo', yet when I view the tree tag I
> get a '+' (no title or id). If I delete the bar folder, the tree tag code
> returns nothing (as I want).
> 
> Is there a way to shortcut the recursive nature of the tree tag to keep it
> from returning the '+' when it contains subfolders?
> 
> Thanks,
> 
> ---
> 
> John Eikenberry
> [jae@kavi.com] 
> ______________________________________________________________
> "A society that will trade a little liberty for a little order
>  will deserve neither and lose both."
>                                          --B. Franklin

--
### Martin Dougiamas -- Internet Agent          is == i see
### Centre for Educational Advancement
### http://cea.curtin.edu/staff/martin