create new tag
, view all tags

TWiki Usability Tricks Pt1: Turn your index into a sitemap

2007-09-12 - 16:09:53 by CarloSchulz in Usability
If you are scanning one of the current indexes (WebTopicList and WebIndex) for a specific topic you have no idea which other topics are related e.g. which topics are child topics.

With the help of TreePlugin you can easily turn your index into a sitemap. As you can see in the screenshot all topics are displayed by hierarchy and alphabet.


How To:

  • The top level topic in this example is the WebHome (renamed in this example).
    • Therefore the WebHome needs to be the root of all topics in your web.

  • To get all the Web* Topic out of the normal list I introduced a topic called "SystemSeiten" (which means SystemTopis)
    • This topic becomes root topic of all topics that start with Web*.

  • To keep the indexes in the TWIKIWEB intact and update safe I created a topic called WebSiteMap in my TWIKIWEB with the following code:

---+ Site Map of %BASEWEB%

*Site maps in other webs:*: %WEBLIST{format="[[$name]]" separator=", "}%

<div style="border:1px solid silver; background:#EFEFEF; padding:10px; font-size:90%; line-height: 1.5;">
%TREE{web="%BASEWEB%" formatting="ullist"}%

  • This produces the above output.

  • If you simply put %INCLUDE{"TWiki.WebSiteMap"}% in each of your webs index topics you have a handy site map and index in one.
    • and you can easily jump to sitemaps in other webs.

NOTE: This was tested on Twiki installation with relatively few topics. I don't know how this works if you have several thousands of topics. But it works very well on our TWiki.

The next step would be to use some JavaScript to fold and unfold the hierarchy levels.


FranzJosefGigler - 12 Sep 2007:

Carlo, have you ever tried TreeBrowserPlugin?

CarloSchulz - 13 Sep 2007:

I tried to combine it with TreePlugin but I had give up on this one because it didn't work as documented.

MarcoSilva - 16 Sep 2007:

Nice tip, I would like to try but without the TreePlugin, using only inline search did you try ? Maybe with METASEARCH variable. Anyway thks the tip.

SteveJonesST - 19 Sep 2007:

Hi Carlo.

I got the TreeBrowser and TreePlugin working together like this:

%TREEBROWSER{"thread" title="<h3>Topic Tree Of %WEB%</h3>" openAll="on"}%
%TREEVIEW{formatting="outline" format="* [[$topic]]" levelprefix="   "}%

I put one of these in every new web created. Hope it's helpful.

JacekZapotoczny - 20 Sep 2007:

We wanted to publish sitemaps from selected webs on a Main. To do this we've used formatting as stated above by Steve. But unfortunately including such a number of sitemaps to a single topic was time consuming while the loading time of a homepage was crucial for us. Then we've found a plugin combination which helped us (TwistyPlugin, TreePlugin, TWikiAjaxContrib). Here I'll try to explain the essentials.

First (TreePlugin) for each web there was created a WebSiteMap topic with the following content:

%TREEVIEW{web="%WEB%" excludetopic="Web*"  formatting="outline" format="* [[%WEB%.$topic][$topic]] " levelprefix="   "}% 

Next (TwistyPlugin) On Main.WebHome we've defined for each of the topics the following:

[[WEB1.%HOMETOPIC%][ __WEB1 web__ ]]
%TWISTY{id="WEB1SiteMap" mode="div" showlink="Show !SiteMap..." hidelink="Hide !SiteMap" 
hideimgleft="%ICONURLPATH{toggleclose-small}%" remember="on"}%
<div id="WEB1SiteMap" style="border-left:1px solid grey"></div>

[[WEB2.%HOMETOPIC%][ __WEB2 web__ ]]
%TWISTY{id="WEB2SiteMap" mode="div" showlink="Show !SiteMap..." hidelink="Hide !SiteMap" 
hideimgleft="%ICONURLPATH{toggleclose-small}%" remember="on"}%
<div id="WEB2SiteMap" style="border-left:1px solid grey"></div>

where WEB1 and WEB2 are the names of existing webs.

And last (TWikiAjaxContrib), we've added some JS code to fill up div's with a content on demand (onclick).

To do that first add some JS to the page header with %AJAX% tag placed at the begining of the page. Then place the following to the bottom of the page.

<script type="text/javascript">
// <![CDATA[
// Load onclick
   twiki.AjaxRequest.setProperties( "WEB1SiteMap", {container:"WEB1SiteMap", url:"%SCRIPTURL{"view"}%/WEB1/WebSiteMap?skin=text", cache:true });
   twiki.AjaxRequest.setProperties( "WEB2SiteMap",   {container:"WEB2SiteMap",   url:"%SCRIPTURL{"view"}%/WEB2/WebSiteMap?skin=text", cache:true });

var myrules = {
   '#WEB1SiteMapshow' : function(el) {
      var oldOnClick = el.onclick;
      el.onclick = function() {
         return false;
   '#WEB2SiteMapshow' : function(el) {
      var oldOnClick = el.onclick;
      el.onclick = function() {
         return false;


//Failure handler
function handleFailed(inName, inStatus) {
   var msg = "<div style=\"background:#ffc; padding:.5em;\">" + 
      "Could not load contents." + 
   twiki.HTML.setHtmlOfElementWithId(inName, msg);
//   alert(msg);
// ]]>

TIP The trick is we don't load WebSiteMaps just on homepage open but only when the user requests it. This saves a lot of time on homepage load which takes now 1.6s according to Apache Benchmark. And the last but not least it looks pretty fancy on the page wink

CarloSchulz - 20 Sep 2007:

Sweet, thanks a lot everyone. Will try to refactor this into a new article.

SeanCMorgan - 27 Aug 2008:

For more on this subject, see HowToEditWebTopicList.

Since I wrote that, I've decided not to reparent the orphaned pages, but rather just to leave them out of the tree by default (and a link to refresh the page with the orphans showing). That's because all my 'adoption' work on the TWiki web was lost when I upgraded.

I also moved the alphabetical list to a separate topic (instead of hiding it in a twisty) to make the page load faster.

P.S. MarcoSilva (16 Sep 2007) wrote, "I would like to try but without the TreePlugin". You can make a SiteMapUsingNestedSearch, but I wouldn't recommend it (TreePlugin is faster).


Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng sitemap.png r2 r1 manage 22.7 K 2007-09-12 - 15:57 CarloSchulz  
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2007-09-13 - CarloSchulz

Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Help
  • 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-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.