Introduction

Sometimes it would be nice to have "left bars" (i.e. sidebars) which correspond to a particular topic. For example, if you go to AtlasComputing you will see a left bar which gives links to the major areas of Atlas computing. However if you follow links to e.g. InnerDetectorSoftware the left bar is now specific to this topic.

Basics

So... how do you do this? After some investigation, Steven Goldfarb and I convinced ourselves that it's not a feature that's natively included in Twiki, so we decided to see if we could do it ourselves. After some (a lot!) of experimentation (mainly by Steve) the scheme we came up with (and which is used by Atlas) was to modify the standard WebLeftBar topic... for example, going to AtlasComputing, and any subsequent pages and you will see that there are some elements to the left bar which stay the same. This is because all the TWiki does is load the standard WebLeftBar for each page... and then we used the magic of "Twiki Variables" to load our own topic-specific left bars.

So we have the basic left bar, which has elements that are common to all ATLAS topics, and then it tries to include a page based on the current topic's name + the generic postscript 'LeftBar' i.e. if the current topic is MyPage, the standard left bar tries to include MyPageLeftBar.

Details

Of course it's best to have a look at WebLeftBar (click on "view as raw" to see the 'meat' of the page), but below I'll break down what it does.

So, here's the standard bit:

<div class="twikiLeftBarSearch" align="center">
  __[[WebSearch][%GREEN% Search %ENDCOLOR%]]__
</div>

This creates a green link to the standard search page (always useful to have to hand...)

Next we have:

<div class="twikiLeftBarPersonal" &gt;
   * __[[%HOMETOPIC%][%RED% %INCLUDINGWEB% Home %ENDCOLOR%]]__
      * [[AtlasDetectors][Detectors]]
      * [[AtlasComputing][Computing]]
      * [[AtlasPhysics][Physics]]
</div>
... which just creates some standard links which should be common to all ATLAS pages.

Finally we have:

<div class="twikiLeftBarBase">
  %INCLUDE{"%BASEWEB%.%BASETOPIC%LeftBar" warn ="<a href=
\"%SCRIPTURLPATH%/edit%SCRIPTSUFFIX%/%BASEWEB%/%BASETOPIC%LeftBar?templatetopic
=%BASEWEB%.WebLeftBarTemplate\">
Create</a> a <nop>LeftBar</nop>"}%
</div>
this tries to include MyPageLeftBar, where MyPage is substituted in from the wiki variable "BASETOPIC". The clever bit is that if this doesn't exist yet, then a link appears saying "Create a LeftBar?" ... if you click on this, then the specific left bar for this page is created, using a template (see the next section) ... and the next time you reload MyPage you should (hopefully!) see the matching left bar.

(I said "finally" above, but in fact in ATLAS we now have several other sections... for example allowing the creation of Personal left bars, and a further 'search' link ... but hopefully these make sense from what's already been explained.)

Create a template

It's a very good idea to create a 'template' left bar for several reasons:
  • most pages can reuse the same "left bar" ... for example, AtlasComputingLeftBar is reused over and over again, as several others.
  • it makes it easier for users
  • it encourages a consistent style.

So in ATLAS we have : WebLeftBarTemplate (again click on "raw text" to see the actual wiki code)

Testing

So suppose you want to try this yourself, in your part of the TWiki what should you do?

Well, firstly copy the 'meat' from WebLeftBar... i.e. the last bit of twiki code listed above (but copy from WebLeftBar to make sure the formatting is correct). Then go back to a standard topic in your web - you should see "Create a LeftBar?" at the bottom.

Before you follow that link you need to create the template left bar ... create a new topic called "WebLeftBarTemplate"... it's probably a good idea to once again copy the basic design from WebLeftBarTemplate

Now you should be done!

-- EdwardMoyse - 24 Feb 2006

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2006-02-24 - EdwardMoyse
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright &© 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback