Tags:
create new tag
, view all tags

Feature Proposal: The WEBLIST feature could be improved with a depth limit

Motivation

Because webs (and sub-webs) allow security inheritance we are looking at implementing a considerable number of sub-webs in one of our webs for student use. But we don't want to bloat the web list that appears in the navigation menu.

Description and Documentation

I've modified our install already in what I think is a suitable solution. It would be good to see if others agree (bit rusty on perl, and very limited modifications to TWiki to date), and indeed if they are interested in a similar feature.

Examples

/lib/TWiki/Store.pm

sub getListOfWebs {
    my ($this, $filter, $web, $depth) = @_;
    ...
    if (! defined($depth)) {$depth = -1;}
    ...
    my @webList = _getSubWebs( $this, $web, $depth );
    ...
}

sub _getSubWebs {
    my ($this, $web, $depth) = @_;
    my @webList;
    if ($depth == -1 || $depth > 0) {
      if ($depth = -1) {$depth -= 1;}
        @webList = $handler->getWebNames();
          ...
          push(@subWebList, _getSubWebs($this, $subWeb, $depth));
      }
    }
    return @webList;
}

/lib/TWiki.pm

sub WEBLIST {
    ...
    my $depth = $params->{depth} || -1;
        ...
        push( @list, $this->{store}->getListOfWebs( 'user,public,allowed', $showWeb, $depth ) );
        ...
        push( @list, $this->{store}->getListOfWebs( 'template,allowed', $showWeb, $depth ));
        ...
}

WEBLIST{"format"} -- index of all webs

  • List of all webs. Obfusticated webs are excluded, e.g. webs with a NOSEARCHALL = on preference variable. The "format" defines the format of one web item. The $name variable gets expanded to the name of the web, $qname gets expanded to double quoted name, $marker to marker where web matches selection.
  • Syntax: %WEBLIST{"format" ...}%
  • Supported parameters:
    Parameter: Description: Default:
    "format" Format of one line, may include $name (the name of the web), $qname (the name of the web in double quotes), $indentedname (the name of the web with parent web names replaced by indents, for use in indented lists), and $marker (which expands to marker for the item matching selection only) "$name"
    format="format" (Alternative to above) "$name"
    separator=", " Line separator "$n" (new line)
    web="" if you specify $web in format, it will be replaced with this ""
    webs="public" Comma separated list of webs, public expands to all non-hidden.
    NOTE: Administrators will see all webs, not just the public ones
    "public"
    marker="selected" Text for $marker if the item matches selection "selected"
    selection="%WEB%" Current value to be selected in list selection="%WEB%"
    subwebs="Sandbox" show webs that are a sub-web of this one (recursivly) ""
    depth="2" Limits the display of sub-webs to a maximum depth.
    -1 or 0 = No limit,
    1 = Only top level webs,
    2 = Top webs and 1st level children only etc.
    "-1"
  • Example: %WEBLIST{"   * [[$name.WebHome]]"}% - creates a bullet list of all webs.
  • Example: <form><select name="web"> %WEBLIST{"<option $marker value=$qname>$name</option>" webs="Trash, public" selection="%WEB%" separator=" "}% </select></form> - creates a dropdown of all public webs + Trash web, with the current web highlighted.

Impact

Implementation

-- Contributors: GregPendlebury - 20 May 2008

Discussion

More than just limiting the number of subweb levels what I have been playing with is a feature where the WEBLIST only shows subwebs if they are below the current web.

Same reason. If I start having subwebs below our already very long list of webs the left bar becomes a mess.

-- KennethLavrsen - 20 May 2008

Sensible idea. Go for it.

-- CrawfordCurrie - 20 May 2008

Other option: use FlexWebListPlugin

-- MichaelDaum - 20 May 2008

I have looked at the FlexWebListPlugin before. And I concluded from the documentation that it could not explode only current web.

Am I wrong?

That plugin could really need a better documentation. It has a near one liner description, a ton of options with one liner descriptions.

What is the syntax for showing only subwebs under current web?

I have tried %FLEXWEBLIST{format="$indent * $name$n" subwebs="only"}% but that only shows the subwebs.

I have tried %FLEXWEBLIST{format="$indent * $name$n" subwebs="Codev"}% but that does not show the top level webs then.

I want to list all the top level webs + all subwebs under the current web and I cannot see how I can do this with FlexWebListPlugin

I am not sure how you will do the depth thing Greg requested.

-- KennethLavrsen - 20 May 2008

Hmm, I had to change the code a tad in '_getSubWebs'. My first attempt was errorring out because @weblist was undefined for users who weren't logged in. Testing ftw!

-- GregPendlebury - 21 May 2008

Also, I had a quick look at FlexWebListPlugin and noticed a depth option there. Haven't explored it though since I'd already coded our solution.

-- GregPendlebury - 21 May 2008

Kenneth, have a look at FlexWebListExamples.

-- MichaelDaum - 21 May 2008

I looked. I do not find a solution to my need there.

-- KennethLavrsen - 22 May 2008

See the example that the subwebs of the Sandbox web.

-- MichaelDaum - 22 May 2008

I find this a small and useful enhancement for the core! One minor detail: For consistency, worth checking if the word depth is aligned with parameter names of existing variables, if any.

-- PeterThoeny - 22 May 2008

Ping. Small and useful feature proposal, with code. Any owner?

-- PeterThoeny - 2009-11-24

how to use it in??

%WEBLIST{" * <span style=\"white-space:nowrap\"><a href=\"%SCRIPTURLPATH{"view"}%/$name/%HOMETOPIC%\"><img src=\"%ICONURL{web-bg}%\" border=\"0\" alt=\"\" width=\"16\" height=\"16\" style=\"background-color:%$markerVAR{\"WEBBGCOLOR\" web=$qname}$marker%\" /> <nop>$indentedname</a></span>"}%

please help

-- LukaszRutkowski - 2012-03-27

Lukasz, please ask support questions in the Support web.

-- PeterThoeny - 2012-03-27

Actually, this is a proposed feature. It has not been implemented. TWiki is open source software. I invite you to get involved, fix/enhance part of TWiki, and contribute it back to the community.

-- PeterThoeny - 2012-03-27

Edit | Attach | Watch | Print version | History: r14 < r13 < r12 < r11 < r10 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r14 - 2012-03-27 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.