Tags:
create new tag
, view all tags
This patch description was abstracted from PatternSkinCodeChanges by CrawfordCurrie - 08 Jul 2004

Sidebar navigation with parent-children patch

  • Status: Ready for inclusion (but needs checking of course)
  • License: GPL (just for clarity)
  • Summary: Adds format parameter to %METASEARCH% (handleMetaSearch). Adds alttext parameter to %META{"parent"}% (renderParent).

SidebarNav.png

I created this navigation for the side bar to easier navigate a topic's parent and children. You can see the parent in the breadcrumb of course, but to see the children is a useful addition.

The sidebar contains a table, where the parent-children part consists of a couple of TRs. These are drawn dynamically, as each row is a result of a query.

Below is a stripped-down version of the table, without icons and styles to show the principle. The code needs to be in a template, not in a topic text, because in text the

%META{"parent"}
won't get rendered.
<table border="1">
%META{"parent" dontrecurse="1" prefix="<tr><td></td><td>-^-</td><td>" suffix="</td>
<td></td></tr>" alttext="<tr><td colspan='4' style='height: 0px;'></td></tr>" }%
   <tr>
   <td></td>
   <th colspan='2'><nop>%INCLUDINGTOPIC%</th>
   <td></td>
   </tr>
   %METASEARCH{type="parent" topic="%INCLUDINGTOPIC%" format="<tr><td></td><td>-v-</td>
<td> $topic </td><td></td></tr>" alttext="<tr><td colspan='4'></td></tr>"}%
</table>

This is the full code I used in the sidebar (beware of introduced newlines):

%META{"parent" dontrecurse="1" prefix="<tr><td class='sbcol1'></td>
<td class='sbcol2' style='background-color: white; border-top: 1px solid #DDDDDD; border-left: 1px solid #DDDDDD;'>%PARENTIMAGE%</td>
<td class='sbcol3' style='background-color: white; border-top: 1px solid #DDDDDD;'>" suffix="</td>
<td class='sbcol4' style='background-color: #DDDDDD; '></td></tr>" alttext="<tr><td class='sbcol1' style='padding: 0px; margin: 0px; height: 0px;'></td>
<td colspan='2' style='padding: 0px; margin: 0px; background-color: white; height:0px; border-top: 1px solid #DDDDDD;'></td>
<td class='sbcol4' style='padding: 0px; margin: 0px; height:0px;'></td></tr>" }%
   <tr>
   <td class="sbcol1"></td>
   <th colspan='2' class="link" style="color: #222222; background-color: white; padding-top:2px; padding-bottom:2px; border-left: 1px solid #DDDDDD;"><nop>%INCLUDINGSPACEDTOPIC%</th>
   <td class="sbcol4" style='background-color: #DDDDDD; '></td>
   </tr>
   %METASEARCH{type="parent" topic="%INCLUDINGTOPIC%" format="<tr><td class='sbcol1'></td><td class='sbcol2' style='background-color: white; padding-top: 1px; border-left: 1px solid #DDDDDD;'>%CHILDIMAGE%</td><td class='sbcol3' style='background-color: white; '> $topic </td><td class='sbcol4' style='background-color: #DDDDDD; '></td></tr>" alttext="<tr><td class='sbcol1' style='padding: 0px; margin: 0px; height:0px;'></td><td colspan='2' class='link' style='padding: 0px; margin: 0px; height: 0px;'></td><td class='sbcol4' style='padding: 0px; margin: 0px; height: 0px;'></td></tr>"}%

In order to make this work, I changed TWiki.pm: methods handleMetaSearch (to use format) and renderParent (to use alttext). See patch sidebar_nav.diff. The %PARENTIMAGE% and %CHILDIMAGE% I used in the HTML are defined in my TWiki.TWikiPreferences, and are substituted for small icons. %INCLUDINGSPACEDTOPIC% is the including topic rendered with spaces where there are underscores.

Known problems

A problem not related to the patch but to the use of META on every page: a lot of templates that do not use View do not render META functions. So I had to create a simplesidebar where I leave out the parent-children block. But of course this gives me double work for each update.

Possible solutions

Let each template / page render META.

-- ArthurClemens

This is now supported by FormattedSearchWithParentTopic, however probaly with some performance penalty. Should be looked at in DakarRelease.

-- PeterThoeny - 04 Aug 2004

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng SidebarNav.png r1 manage 8.5 K 2003-08-13 - 21:27 ArthurClemens Screenshot of sidebar navigation
Unknown file formatdiff sidebar_nav.diff r1 manage 1.8 K 2003-08-13 - 21:58 ArthurClemens Patch file to enable sidebar with parent-children
Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r8 - 2006-06-26 - ArthurClemens
 
  • 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.