On Saturday, February 14, 2015 at 4:46:08 PM UTC-8, Paul Lee wrote:
>
> Is there a way either to set a variable in the destination tiddler of a 
> link, or else to call a conditional based on filter operators 
> <http://tiddlywiki.com/static/Filters.html> to select between different 
> possible destination tiddlers?
>
> I wish syntax like this were possible:
>
> [[link|DestinationTiddler with:"You see a tree stump here."]]
>
> Of course, DestinationTiddler can be a wrapper that transcludes a 
> different tiddler containing the real content, so that DestinationTiddler 
> would set the variable:
> <<tiddler ContentTiddler with:"You see a tree stump here.">>
>
> This is the solution I'm currently using, but it's limitation is that it 
> requires different destination tiddlers. To call a different text, you 
> would need a DestinationTiddler2 to call ContentTiddler with a different 
> variable. The reader will be able to tell that it is a different tiddler 
> because the heading will be different.
>

There are two problems here:
* The first is that the link syntax doesn't support use of "with: ..."
* The second is much bigger: parameter substitution is processed by the 
transclusion macro (<<tiddler>>), but there is no general architecture for 
*directly* substituting markers when a tiddler is simply opened in the 
story column.

One way around this... use HTML to create a tiddler link that sets global 
variable(s) as a side-effect, and then use syntax within the target tiddler 
to retrieve and display the values stored in the global variable(s). 
 Here's one possible implementation, using just standard TWC syntax with a 
little embedded HTML:

First, create a tiddler called [[LinkThis]], containing the following HTML:
--------------------------------
<html><a href="javascript:;" onclick="
   config.myVars = { $3 };
   story.displayTiddler(story.findContainingTiddler(this),'$2');
   story.refreshTiddler('$2',null,true);
   return false;
">$1</a></html>
--------------------------------
In the above content, $1 is the link text, $2 is the target tiddler title, 
and $3 is the global variables to set, using standard javascript object 
syntax.

2) In the "calling" tiddler (e.g., [[FromHere]]), embed:
--------------------------------
<<tiddler LinkThis with: "click me 1" [[ToHere]] [[valueA:'AAAAA', 
valueB:'BBBBB']]>>
<<tiddler LinkThis with: "click me 2" [[ToHere]] [[valueA:'CCCCC', 
valueB:'DDDDD']]>>
--------------------------------
Note one limitation: you can't use double-quotes in the parameter where you 
set the values, as this will conflict with the use of double quotes in the 
HTML syntax contained in LinkThis, and you need to use single-quotes around 
the values you set, so neither type of quote is available for use as 
literal text within the value itself.

3) In the "target" tiddler (e.g., [[ToHere]]), embed:
--------------------------------
This is a variable, "valueA": <<message myVars.valueA>>
This is another variable, "valueB": <<message myVars.valueB>>
--------------------------------
The <<message>> macro renders the global values that were stored by the 
LinkThis HTML code.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

"Inside TiddlyWiki: The Missing Manual"
https://www.indiegogo.com/projects/inside-tiddlywiki-the-missing-manual/x/8816263

YOUR ONGOING DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...
   http://TiddlyTools.github.com/fundraising.html#MakeADonation

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
   http://www.TiddlyTools.com/#Contact

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Reply via email to