[Zope] nav trees

Ze Octavio joc@hiper.com.br
Wed, 23 Jun 1999 18:30:11 -0300


Hi Daniel,

There are a lot of features not documented about tree tag, I like to
thank Martijin Pieters for the good playing around with TreeTag.py, help
us with a lot of hidden features. Martjin sent an email on 17 Feb, I
will send againd in the final of this email.

To solve your problem you have to do an IF, like the following:

<!--#tree sort=title-->
   <!--#if "_['tree-level'] == 0"-->
      <IMG SRC="<!--#var SCRIPT_NAME-->/<!--#var icon-->">
      <!--#var title--> 
   <!--#else-->
      <a href="categorias/<!--#var tree-item-url-->/"> <!--#var
title-->       </a>
   <!--#/if-->
<!--#/tree-->

   So you can play with the levels of the tree to choose when do you
want to do something. In the example, in the first level, I didn't want
link in titles, but in the all next levels I do. And only in the first
level we have the folder icon.

    I hope you enjoy the informations.

-- 
Ze Octavio
--
Hiperlógica <http://hiper.com.br>
Automação de web-sites | Web-site automation
São Paulo | Brasil | Fone: +55-11-251-4894

The email sent by Martjin begins from this point:

At Tue, 02 Feb 1999 13:01:32 -0800 Amos Latteier wrote a nice
explanation
of the branches attribute of the tree tag.

But when I played around with the source of the tree tag (TreeTag.py), I
discovered more toys. This is has become an unofficial documentation of
the
#tree tag. Excuse the typos, for it has become very late. Have fun.


Attributes of #tree

assume_children=[0|1] default 0
        If set to a nonzero value, all items are assumed to have
subitems, and
will therefore allways have a + sign in front of them when not yet
expanded. Only when a user expands an item it is checked for subitems.
This
could be a good option when the retrieval of children is a slow process.

branches="methodname" default="tpValues"
        If an object has defined this method, it should return a list of
ids that
are it's subobjects. The default, tpValues, is defined on the Items
class
(from which just about every objetc inherits), and Folders and Database
Adapters define their own versions. If you use objectValues as method,
you
get the same effect on Folders, but not on Database Adapters.

branches_expr="expression"
        branches_expr works like the expr attribute of tags like #if.
You could
therefore do:
<!--#tree branches_expr="objectValues(['Folder', 'DTML Document'])"--> 
to get a tree of only Folder and Document subobjects. This is easier
than
defining your own External Method for branches="", like Amos described.

id="method_or_propertyname" default="tpId"
        Method or property name to determine the ID of the object for
tree-state
purposes. The Ids saved in the tree state cookie (and the tree-state
local
var) are realy just integers so the state var is not too big, but
unusable
for your average Zope developer. If you want to do anything with the
state,
you might want to define this as id="id", for a more readable form. 
Just do 
<!--#tree id="id"--><!--#var tree-state--><!--#/tree--> and see for
yourself. No default Zope object currently defines a tpId method or
property. When no tpId method or property is defined, an internally
generated integer is used (pickle id?).

leaves="property"
        If set, this property is assumed to be a DTML Method within
objects that
have no sub-objects. It is displayed as part of the tree, no additional
code is needed in your DTML. The leave DTML method is handed a special
standard_html_header and standard_html_footer.

nowrap=[0|1] default 0
        If set to a nonzero value, the tree table will be rendered with
the NOWRAP
attribute, which means the browser won't wrap the item labels when
spacially challenged.

url="method_or_propertyname" default="tpURL"
        Method or property to be called on object to determine the
relative URL of
the object. The default, tpURL, is defined by the Item class, and the
Gladfly Database Adapter defines it's own version, so it can show you
it's
tables and columns in the management screen. If you want to override the
URL translation, define an External Method, like Amos described, and use
that method with url="methodname".

single=[0|1] default 0
        If set to a nonzero value, only one branch on a level can be
expanded. Any
other expanded branches will collapse. Seriously cool.

skip_unauthorized=[0|1] default 0
        If set to a nonzero value, no ValidationErrors will be raised
trying to
read objects to which the user has no access.



Variables in namespace set by tree tag (for every object being
rendered):

tree-root-url
        Relative URL of the DTML Document or Method this tag is in.

tree-colspan
        The number of levels deep the tree is being rendered.

tree-state
        The current state of the tree, a list of ids and sublists.

tree-item-url
        The URL of the current object being rendered, relative to the
document the
#tree tag is in. This is generated using the url="methodname" method.

tree-level
        Level of this object in the tree, starting at 0.

tree-item-expanded
        Flag indicating wether this item is expanded or not.



Variables in namespace that influence the tree tag:

expand-all
        All branches expanded if this name is defined and nonzero (like
in a
cookie, or in the REQUEST object. Try
http://URL/to/object/with/tree/tag?expand-all=1).

collapse-all
        All branches collapsed if present and nonzero.  

tree-s
        This is the cookie and query name that contains the state of the
tree.
This is a zlib compressed, base64 encoded nested list of ID's. Have fun
making one yourself. I think you better start with the TreeTag.py code.

tree-e
        List of ID's to expand. See tree-s on the format.

tree-c
        List of ID's to collapse. Again, see tree-s.



Are we going to collect this kind of data somewhere? Like in a tag
reference? 
Is there a protocol to define your own DTML tags?


"Daniel M. Drucker" wrote:
> 
> I'm using a tree tag for a navagation system which you can see at
> http://www.3e.org/elena/ . The problem I'm having is that if you click
> on the title of a folder (instead of on the +/- like you're supposed
> to), you end up with another copy of the site nested in the target
> frame.
> 
> How would I make it so the folder names would *not* be links?
> 
> Daniel Drucker
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://www.zope.org/mailman/listinfo/zope
> 
> (For developer-specific issues, use the companion list,
> zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )