[Zope-dev] ZTopic displays wrong tabs

Steve Alexander steve@cat-box.net
Wed, 28 Jun 2000 18:17:42 +0100


Hi folks,

I'm using ZTopic.

One thing I've noticed about the management interface is that, although
an appropriate tab is highlighted when you click that tab, if you go to
a subsequent screen, often "contents" will erroneously become the
highlighted tab.

This is causing problems as I explain to non-technical folk how to use
ZTopics. I say "select the contents tab", and they say "but the contents
tab **is** selected!".

I have a fix for this, but the real problem is in the logic of
lib/python/App/manage_tabs.dtml:

<dtml-call "REQUEST.set('a_', 0)">
<dtml-in manage_options mapping>
<dtml-if expr="URL[-(_.len(action)):]==action or
                URL[-17:]=='/manage_workspace' and _['sequence-start']">
<dtml-call "REQUEST.set('a_', _['sequence-index'])">
</dtml-if>
</dtml-in>

Here, the variable 'a_' represents the "active" tab. If the last part of
the URL matches one of the manage_options of the current object, then
that tab will be the highlighted one. Otherwise, the first tab will be
highlighted.

It should ideally be possible to tell manage_tabs what tab should be
highlighted, imperatively, when required.

However, in the absence of such a mechanism, I have changed the DTML
files in ZTopic like this:

The form searchEdit.dtml is really part of the "Search Criteria" logic,
so I want that tab highlighted. That tab's action attribute is called
"editForm". Therefore, in the file searchEdit.dtml, I replace this:

    <BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
    <!--#var manage_tabs-->
    
    <p>Edit catalog search criterion number <dtml-var "index+1">
    on Catalog <strong><dtml-var catalog_id></strong>.</p>


With this:

    <BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
    <dtml-with "_.namespace(URL='editForm')">
      <dtml-var manage_tabs>
    </dtml-with>
    
    <p>Edit catalog search criterion number <dtml-var "index+1">
    on Catalog <strong><dtml-var catalog_id></strong>.</p>

(I modernised the <!--#var ...--> to <dtml-var ...> along the way.)

To get the full effect, you'd need to do a similar trick with the other
dtml files in ZTopic.

Any takers for a full patch?  Or, is there a better way of doing this
that I don't know about?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net