r8 - 26 Jun 2006 - 23:46:29 - ArthurClemensYou are here: TWiki >  Codev Web > SidebarNavigationWithParent
Tags:
, create new tag
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 Action Size Date Who Comment
pngpng SidebarNav.png manage 8.5 K 13 Aug 2003 - 21:27 ArthurClemens Screenshot of sidebar navigation
elsediff sidebar_nav.diff manage 1.8 K 13 Aug 2003 - 21:58 ArthurClemens Patch file to enable sidebar with parent-children
Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r8 < r7 < r6 < r5 < r4 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback SourceForge.net Logo