Note: An alternative skin, TW4MW (work in progress), is available from the user preferences.

HideWhenPlugin/Questions

TiddlyWiki Community Wiki

Jump to: navigation, search
This page's contents need to be reviewed and/or refactored to comply with TiddlyWiki.org's quality standards.
Please improve the article, or discuss the issue on the talk page.

FAQ about using the HideWhenPlugin from MonkeyPirateTiddlyWiki.

[edit] Using HideWhen to do conditional toolbars based on user name

Replace the normal toolbar comand in the ViewTemplate tiddler with the following:

<div class='toolbar' macro="showWhen config.options.txtUserName == 'BartSimpson' "> 
    <span macro='toolbar editTiddler closeOthers closeTiddler'></span>
</div>
<div class='toolbar'  macro="showWhen config.options.txtUserName != 'BartSimpson' ">
     <span macro='toolbar closeOthers closeTiddler'>&lt/span>
</div>

[edit] Using HideWhen to do conditional fields based on tags

Let suppose you have a some tiddlers tagged with "friend" and you'd like to use some custom field to maintain some information about them, say their favourite food.

In ViewTemplate:

<div macro="showWhen tiddler.tags.contains('friend')">
  Favourite food: <span macro="view favouritefood"></span>
</div>

In EditTemplate:

<div macro="showWhen tiddler.tags.contains('friend')">
  Favourite food: <span macro="edit favouritefood"></span>
</div>

Now you can view and edit your friends' favourite food.

If you wish to have the same field show for your business contacts as well as your friends then you would do it like this:

In EditTemplate:

 <div macro="showWhen tiddler.tags.containsAny(['friend','contact'])">
   Favourite food: <span macro="edit favouritefood"></span>
 </div>

In ViewTemplate:

 <div macro="showWhen tiddler.tags.containsAny(['friend','contact'])">
   Favourite food: <span macro="view favouritefood"></span>
 </div>

Note that custom fields must be lower case. See http://trac.tiddlywiki.org/ticket/356 for details.

[edit] Making editable custom fields appear on a new tiddler

Create a customized newTiddler button:

 <<newTiddler label:'Add Training' tag:'Training' title:'New Training'>>

Place the following in the EditTemplate:

 <div macro="showWhen tiddler.tags.contains('Training') || tiddler.title == 'New Training'"> 
   [[TrainingTemplateEdit]]
 </div>

Create a TrainingTemplateEdit tiddler to put all of your desired custom fields in.

Placing each collection of custom fields in a separate tiddler helps cut down on the confusion of having multiple different things going on in your ViewTemplate & EditTemplate, as well as making it easier to safe guard against accidentally deleting or over writing one of them and losing everything.

Personal tools