including text in multiple tiddlers ?

78 views
Skip to first unread message

techwriter_mjs

unread,
Feb 16, 2011, 9:43:02 AM2/16/11
to TiddlyWiki
Hello, TiddlyWiki community,

You've already answered so many of my questions recently, but I have
another one -- is there a way to include the same text in multiple
tiddlers?

For example, I'd like to include a bunch of terms-and-definitions in
both a Glossary tiddler and a GettingStarted tiddler, and I certainly
don't want to have to maintain the list in two places. I know I could
put each term in its own tiddler and then have a list of those
glossary tiddlers, but that would require the reader to click to open
every one.

I thought of creating a ShowTiddlerText tiddler that would be similar
to ShowPopup, but have it show the tiddler's text (but not its title)
without requiring any action by the reader, But I haven't gotten it
to work yet. And so before I spend lots more time trying to make it
work, I figured it was worth checking to see if there was a plugin or
method that's already been done.

And a final wish would be that I could actually use separate tiddlers
for each term (for example, glossTerm1, glossTerm2) so that they could
be shown using ShowPopup in yet other tiddlers, similar to how Help
procedures often provide hyperlinked popup definitions for unfamiliar
terms.

Many thanks -- And is there a place where I could/should be posting
these tips & tricks that you've all so generously explained to me?

-Monique

whatever

unread,
Feb 16, 2011, 11:48:44 AM2/16/11
to TiddlyWiki
Hi, Monique!
What you're talking about is transclusion (1), which is very easy
indeed. Some basics:
<<tiddler "YourTiddler">> - shows the content of the entire tiddler
<<tiddler "YourTiddler##SectionName">> - shows a specific section of a
tiddler
<<tiddler "YourTiddler::SliceName">> - shows a specific slice of a
tiddler
<<tiddler "YourTiddler/PartName">> - shows a specific part of a
tiddler.
Note that quotation marks are not mandatory, but they are required if
tiddler, section, slice or part name contains spaces. Also, instead of
quotation marks, you can use [[ and ]].

Sections start with !
!SectionName or !!SectionName or !!!SectionName

Slices look like this:
SliceName: SliceContent
or
|SliceName|SliceContent|
The second is actually a table, so if you have a table with glossary
term in one column and definition in another, you can use that.

Parts look like this:
<part PartName>PartContent</part>
For parts you need Udo's PartPlugin (2).

You can also transclude like this:
Create YourTransclusionTiddler which contains the following:
"This $1 is very &2."
Then you can do this:
<<tiddler "YourTransclusionTiddler" with:"fruitcake" "good">>
The result: "This fruitcake is very good."

As for popups with explanations, take a look at Saq's
AnnotationsPlugin.

Also, in case you haven't discovered it yet, Eric's TiddlyTools (4)
contains a gazillion of extremely useful tools and Udo's
ForEachTiddlerPlugin (5) is very useful as well. On TwHelp (6), you
can find plenty of useful examples and explanations and, of course, on
this group as well. :D

w

(1) http://tiddlywiki.org/wiki/Transclusion
(2) http://tiddlywiki.abego-software.de/#PartTiddlerPlugin
(3) http://tiddlywiki.squize.org/#AnnotationsPlugin
(4) http://www.tiddlytools.com
(5) http://tiddlywiki.abego-software.de/#ForEachTiddlerPlugin
(6) http://twhelp.tiddlyspot.com/

Tobias Beer

unread,
Feb 16, 2011, 4:22:13 PM2/16/11
to TiddlyWiki
Here's a solution from Jonathan Visick that might cut it for you. To
see it work, check out [1] and hover over any of the textbits
(abbreviations, strange terms) that look as though they might have a
definition to them.

In order to get something similar working, here's what you need to
do...

1) install Saq's AnnotationsPlugin [2]

2) Create a tiddler, call it "Macros" or use a "zzConfig", tagged
"systemConfig". Put at least the following into it...

config.macros.g = {
handler:function(place,macroName,params){
var dText = params[0].replace(/\'/,"");
if (dText.substring(0,1) == "$") {
var noHead = 1;
dText = dText.substring(1);
}
var gText ="<"+"<tiddler [[Glossary::"+params[1]+"]]>>)))";
if (!noHead){gText = "^" + gText;}
var gEntry="(("+dText+"("+gText;
wikify(gEntry,place,null,null);
return false;
}
}

This is taken from Jonathan Visick's Macros [3].

3) Create a tiddler called "Glossary" containing your glossary terms
in slice:value pairs whereas the slicename would be the identifier for
the glossary entry and the slice value the glossary entry. For an
example, look at [3].

4) In your text add references to your glossary like this...

Here is a sentence referencing to <<g "term xyz" xyz>>.

...which will render as "term xyz", yet when you mouseover it, you
will get an annotation containing the glossary entry for the slice
called "xyz", see [1].

5) You can even add images to the popup by adding the corresponding
wiki syntax. If you don't want to see those images when you view your
Glossary tiddler, simply wrap the whole glossary with a class like so:

{{glossary{
term1:entry for term1 [img[imgTerm1.jpg]]
term2:entry for term2 [img[imgTerm2.jpg]]
}}}

Then add the following to your StyleSheet:
.glossary img {display:none;}

6) An improvement to this system might be to use sections instead of
slices in your glossary tiddler: This would provide a simple means to
use multiple lines, tables, etc. in your annotations. To do that you
would have to change the 'g' macro accordingly, by replacing...

var gText ="<"+"<tiddler [[Glossary::"+params[1]+"]]>>)))";

with...

var gText ="<"+"<tiddler [[Glossary##"+params[1]+"]]>>)))";


Cheers, Tobias.

[1] http://jonathan.visick.faculty.noctrl.edu/research/wiki/#Overview
[2] http://tiddlywiki.squize.org/#AnnotationsPlugin
[3] http://jonathan.visick.faculty.noctrl.edu/research/wiki/#Macros
[4] http://jonathan.visick.faculty.noctrl.edu/research/wiki/#Glossary

Måns

unread,
Feb 16, 2011, 6:44:37 PM2/16/11
to tiddl...@googlegroups.com
Hi Tobias

Great!! Thanks for explaining Jonathan Visick's way of using Saq's AnnotationsPlugin...
To me this is (maybe) a true eyeopener on how to maintain a table (slices) - or chunks of info in sections...

It seems to me that it would/should be really easy to replace Saq's AnnotationsPlugin with Eric's NestedSlidersPlugin for this behaviour??
I'd like to do this - because I like the idea of having clickable popups, and maybe even the ability to expand content in a popup with yet another popup inside of the first one...

How would change the current code to use NestedSlidersPlugin instead of AnnotationsPlugin?

I'm thinking of something in this neighbourhood: @@position:relative;+++^SomeAutoWidthDefinitionIdon'tKnow^@*[xyz]..."<"+"<tiddler [[Glossary##term xyz]]>>===@@
Of course I wouldn't want the "xyz" to show like a button - however I don't know how to set a class to remove the button characteristics and replace it with some css indicating, that it will show a popup when hovered, either....
Hmm - maybe I'm just asking too much :-)

Cheers Måns Mårtensson


Tobias Beer

unread,
Feb 17, 2011, 7:47:11 AM2/17/11
to TiddlyWiki
Hi Måns,

I don't think you're asking too much at all. However, I believe Eric
can answer this question much faster and more comprehensively than I
could.

What it boils down to is merely changing the string replace in the "g"
macro (g as for "glossary") ...which is not an utterly difficult job,
but I am unaware of all options of NestedSlidersPlugin and what needs
concatenation in which way and possibly what needs to be implemented
as another parameter (or document-wide config variable) in the code of
the g macro.

However, I am pretty sure that you can assign any css class you want
to the element that triggers any sliders or popups to open. As for
now, I would want for Eric to skim through this and propose a solution
as I - please excuse my ignorance - just haven't used
NestedSlidersPlugin so far.

Cheers, Tobias.

Måns

unread,
Feb 17, 2011, 10:49:57 AM2/17/11
to tiddl...@googlegroups.com
Hi Tobias



What it boils down to is merely changing the string replace in the "g"
macro (g as for "glossary") ...which is not an utterly difficult job,
but I am unaware of all options of NestedSlidersPlugin and what needs
concatenation in which way and possibly what needs to be implemented
as another parameter (or document-wide config variable) in the code of
the g macro.

I think I just might try that:

Sth like this might work?? (will test later...):

"config.macros.g = { 
handler:function(place,macroName,params){ 
var dText = params[0].replace(/\'/,""); 
if (dText.substring(0,1) == "$") { 
var noHead = 1; 
dText = dText.substring(1); 

var gText =@@position:relative;+++^SomeAutoWidthDefinitionIdon'tKnow^@*[xyz]..."<"+"<tiddler [[Glossary::"+params[1]+"]]>>===@@"; 

if (!noHead){gText = "^" + gText;} 
var gEntry="(("+dText+"("+gText; 
wikify(gEntry,place,null,null); 
return false; 

"
 

However, I am pretty sure that you can assign any css class you want
to the element that triggers any sliders or popups to open. As for
now, I would want for Eric to skim through this and propose a solution

This css class question is probably the easiest part - because I could keep the css class seperate from the script, applying it to the macro output {{someClass{<<g "term xyz" xyz>>}}}... However it *would* be nice to have it all in one script :-)

Thanks for answering my question! 

Cheers Måns Mårtensson

Måns

unread,
Feb 18, 2011, 3:14:48 AM2/18/11
to tiddl...@googlegroups.com
Ok - It turns out that it is a little more complicated that I thought... therefore I made a transclusion instead:
[[Glossary]]
{{noButton{@@position:relative;+++^$2^*@[$1*]...<<tiddler [[Glossary::$1]]>>===@@}}}/%
|xyz|xyz are the last three letters in the alphabet|
|æøå|er de sidste tre bogstaver i alfabetet |
%/
[[StyleSheet]]
/*{{{*/
.noButton .button {border: 1px solid transparent;}
/*}}}*/
[[Test]]
<<tiddler Glossary with: xyz "10em">>

This seems to be exactly what I wanted - so no scripting needed this time...

Cheers Måns Mårtensson

Måns

unread,
Feb 18, 2011, 3:36:03 AM2/18/11
to tiddl...@googlegroups.com
If I change the transclusion to use sections instead of slices and install Eric's EditSectionPlugin, I get a popup which provides editing the annotation in place (hidden when readonly):
[[Glossary]]
{{noButton{@@position:relative;+++^$2^*@[$1*]...<<tiddler [[Glossary##$1]]>><<editSection [[Glossary##$1]] [[✎ »]]>> ===@@}}}/%
!xyz
xyz are the last three letters in the alphabet
!æøå
er de sidste tre bogstaver i alfabetet
!end %/

[[Test]]
<<tiddler Glossary with: xyz "10em">>

Cheers Måns Mårtensson

Tobias Beer

unread,
Feb 18, 2011, 7:08:09 AM2/18/11
to TiddlyWiki
Hello again Måns,

I'll play with your transclusion when I get home tonight and see if I
can provide you an alternative g macro... which seems to make for a
much shorter wiki markup ...after all, this short notation seems to be
of desire when using a glossary entry.

Cheers, Tobias.
Message has been deleted
Message has been deleted
Message has been deleted

Tobias Beer

unread,
Feb 18, 2011, 3:36:15 PM2/18/11
to TiddlyWiki
Hi Måns,

So, here's your spiced up version of the g macro using
NestedSlidersPlugin...

http://pastebin.com/T2Ff08qF

Simply call it using...

This is an entry for <<g xyz "XYZ" 30em>>.

Cheers, Tobias.

Måns

unread,
Feb 18, 2011, 5:08:27 PM2/18/11
to tiddl...@googlegroups.com
 Hi Tobias

:-P

That is some great work you've made!! I am  very impressed and I really like the fact that you've set it up so I can decypher what's going on with the variables!!
Thanks a lot!!
You've even implemented EditSectionsPlugin in an (admin) variable which can be substituted with something else - AND will be hidden when readonly...

GREAT GREAT GREAT :-P

I will try to learn from this great example - and I'm sure this macro (with all those tweakable options) is a perfect template for new macros...

Thanks again Tobias - thanks for sharing it - and some of your magic too :-)

Cheers Måns Mårtensson
Reply all
Reply to author
Forward
0 new messages