[tw] Re: showWhen code in tiddler body

2010-05-15 Thread AlanBCohen
For the rest of us,

This showWhen macro is one of two contained in the HideWhenPlugin by
Simon Baird. I found it in http://www.giffmex.org/twfortherestofus.html

-- 
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlyw...@googlegroups.com.
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.



[tw] Re: showWhen code in tiddler body

2010-05-14 Thread colmjude
Hi Skye,

Are you trying to show a photo in a particular tiddler?
I have never heard of the 'showWhen' macro but there is another way to
show a different img, depending on the protocol type, in a given
tiddler.

Firstly create a tiddler to contain the imgs. Give it 2 sections (one
for local, one for external), like this;

!External
[img[title text|http://path/to/image.jpg]]

!Local
[img[title text|file:///C:/path/to/image.jpg]]

We can now use this in other tiddlers through transclusion (more info
here http://tiddlywiki.org/wiki/Transclusion)
Then in the tiddler where we want either the locally or externally
hosted image to display we can use the tiddler macro and do this:

tiddler {{ if(window.location.protocol == file:){
 ImagesTiddler##Local } else {
ImagesTiddler##External
}
}}

So this performs the check on the protocol and matches it against
file: If it is it outputs ImagesTiddler##Local, which selects just
the !Local slice of the ImagesTiddler tiddler.
This is equivalent to just writing tiddler imagesTiddler##Local.
If it does not match file: it will output the slice required to
display the !External slice.

I hope that solves your problem.

Colm

p.s you could write the snippet above as:
tiddler {{ (window.location.protocol == file:) ?
ImagesTiddler##Local:ImagesTiddler##External }} 
if you want it to look a bit neater.

-- 
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlyw...@googlegroups.com.
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.



[tw] Re: showWhen code in tiddler body

2010-05-14 Thread Eric Shulman
 tiddler {{ if(window.location.protocol == file:){
  ImagesTiddler##Local } else {
 ImagesTiddler##External

 }
 }}

You can also perform 'conditional transclusion' using
   http://www.TiddlyTools.com/#CoreTweaks##890

which adds an optional if parameter that can be used with computed
values to check if the specified tiddler should be transcluded or
not... .like this:

tiddler SomeTiddler##local if:{{window.location.protocol==file:}}

tiddler SomeTiddler##remote if:{{window.location.protocol==http:}}


enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

-- 
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlyw...@googlegroups.com.
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.