I want the replace "project" with a dynamicly generated cndition, a
simple java script for example that returns the tag name of the
current tiddler and then forEachTiddlewr searches for other tiddlers
with that same tag. How do I insert a java script in the place of
"project".
I have InLineJavaScript installed
Using
http://www.TiddlyTools.com/#InlineJavascriptPlugin
you can embed the following script in your tiddler, just before the
<<forEachTiddler>> macro invocation to set a global variable based on
the current tiddlers tag...
<script>
var here=story.findContainingTiddler(place); // rendered DOM
element
if (!here) return; // not in a tiddler... do nothing.
var tid=here.getAttribute("tiddler"); // tiddler ID (title)
var t=store.getTiddler(tid); // stored tiddler data object
config.currentProject=t.tags[0]; // assume *first* (or only) tag
</script>
Then, in your <<forEachTiddler>> call, you can reference that global
variable like this:
'tiddler.tags.contains(config.currentProject)'
Note: "config" is a global object, created by the TW core, and
contains many critical internal TW values (such as config.options.*,
config.macros.* and config.messages.*, among others). Be sure you use
a property name that doesn't step on any of the existing TW core
properties. The best way to ensure this is to give the property name
a distinct prefix such as your initials (e.g.
"config.ELS_currentProject").
enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
Skye
How can the forEachTiddlerPlugin find the tiddlers with *all* these
tags of ShowMe, but *not* the tiddler ShowMe?
-Uwe
Assuming that the tiddler with the <<forEachTiddler>> call is named
ShowMe and has the tags ene, mene, mane, moo.
How can the forEachTiddlerPlugin find the tiddlers with *all* these
tags of ShowMe, but *not* the tiddler ShowMe?
<<forEachTiddler
where 'tiddler != context.inTiddler &&
tiddler.tags.sort().join("]]") == context.inTiddler.tags.sort().join("]]")'
>>
tiddler != context.inTiddler
ensure the tiddler containing the macro call is not listed. tiddler.tags.sort().join("]]")
creates a string with all tags of the tiddler, with the tags sorted
alphabetically and separated by "]]". The "]]" string is used because
it cannot be part of any tag name so it is fine to use it as a
separator between tags. context.inTiddler you may also use context.viewTiddler, especially when you are working with the <<tiddler...>>
macro.it works fine!
Do you also have a solution for the following problem?
Assuming that the tiddler with the <<forEachTiddler>> call is named
ShowMe and has the tags ene and mene.
How can the ForEachTiddlerPlugin find all tiddlers with the tag ene
*or* with the tag mene (or both), when there are perhaps many other
tags in the tiddlers?
(The ForEachTiddlerPlugin must use the tags from the ShowMe tiddler.)
-Uwe
Assuming that the tiddler with the <<forEachTiddler>> call is named
ShowMe and has the tags ene and mene.
How can the ForEachTiddlerPlugin find all tiddlers with the tag ene
*or* with the tag mene (or both), when there are perhaps many other
tags in the tiddlers?
<<forEachTiddler where
'tiddler.tags.containsAny(context.inTiddler.tags)'
... >>
-Uwe