create new tag
, view all tags

Feature Proposal: Add a new optional attribute to the META{"parent" ...} variable to limit number of upstream ancestors


When a deeply nested Topic is viewed using the Pattern skin [or one of many skins that displays the META{"parent"} variable], the page is often rendered very wide, distorting the rest of the page's layout. The addition of an optional attribute (maxelements) is a small change, and completely backwards-compatible; any current unchanged uses of META{"parent"} will be unaffected.


This change would add an optional attribute to the META{"parent"} variable - "maxelements". Once maxelements ancestors have been prepended to the list, all other ancestors are replaced by "...", thus limiting the length of the displayed list. Because the number of elements to be displayed is set on a per-use basis, developers can decide whether this added functionality is useful in a given context, and furthermore to what extent the context calls for the limiting of the ancestory list length.

-- OrrBernstein - 08 Mar 2005

Impact and Available Solutions

Note: Patch is attached as http://twiki.org/p/pub/Codev/MetaParentOptionalLengthLimit/twiki-render-meta-parent-patch.diff. The patch is against the TWikiProductionRelease of 02 Sep 2004 or 01 Sep 2004 (Cairo Release).


The topic, TWikiMetaData (#Rendering_Meta_Data), would need to be changed as such:


At present support is fairly basic:

Variable usage: Comment:
%META{"form"}% Show form data, see Form Templates
%META{"attachments"}% Show attachments, excluding hidden ones. Options:
all="on": Show all attachments i.e. including hidden ones
%META{"moved"}% Details of any topic moves
%META{"parent"}% Show topic parent. Options:
dontrecurse="on": By default recurses up tree, this has some cost.
nowebhome="on": Suppress WebHome.
prefix="...": Prefix that goes before parents, but only if there are parents, default "".
suffix="...": Suffix, only appears if there are parents, default "".
separator="...": Separator between parents, default is " > ".
maxelements="...": Maximum number of upstream ancestors before replacing the rest with "...", default is infinity.



One example is putting the ancestory on the WebTopBar, as a easy navigation mechanism if your TWiki has a good amount of hierarchical organization:

<div class="twikiLeft">
<table border="0" cellpadding="0" cellspacing="0">
<td width="170"<a href="%WIKILOGOURL%"><img src="%WIKILOGOIMG%" border="0" alt="Home"/></a></td>
<td valign="bottom" align="right"><br/><br/>[[%BASEWEB%.WebHome][Codev]] %META{"parent" nowebhome="on" prefix=" < " suffix="" maxelements="2"}% < <nop>%BASETOPIC%</td>
<div class="twikiRight twikiSearchBox">
<table border="0" cellpadding="0" cellspacing="0">
<td><label for="go">Jump: </label><input type="text" id="go" name="topic" size="16" /></td>


After reading in the new attribute,

   my $maxElements = 0;

   if( $args ) {
       $maxElements = TWiki::extractNameValuePair( $args, "maxelements" );

we simply start counting how many elements we've seen - if we reach one past the max (note that we start counting at 0, so we've past the max when the count == the max specified), we add a "..." and break out of the loop.

            my $elementCount = 0;
            $elementCount += 1;
            if( $elementCount == $maxElements ) {
               $text = "...$sep$text";
            } else {
               $text = "[[$pWeb.$pTopic][$pTopic]]$sep$text";
            (this replaces: $text = "[[$pWeb.$pTopic][$pTopic]]$sep$text";)

Small change, but the effect on the visual effect of the trail is noticable.


Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatdiff twiki-render-meta-parent-patch.diff r1 manage 1.3 K 2005-03-08 - 16:06 UnknownUser Unified diff for patching
Topic revision: r1 - 2005-03-08 - OrrBernstein
  • 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.