Variable within an external link reference

128 views
Skip to first unread message

stevesuny

unread,
Nov 15, 2016, 4:32:23 PM11/15/16
to TiddlyWiki
Hello folks,

I'm trying to build a macro that calls an external link from a defined path (similar to  ximg but with a link rather than an image.

I can get this to work:
\define sbk-hardcode-path(linktext,timestamp)
Timestamp: $timestamp$<br>
[[$linktext$|https://designwritestudio.github.io/resources/sbk/data/$timestamp$/index.html]]
\end

* <<sbk-hardcode-path "sbk macro with hardcoded path value" "20161006124524">>

which nicely provides a link to https://designwritestudio.github.io/resources/sbk/data/20161006124512/index.html, as expected.

But, I can't get this to work:
\define sbk(linktext,timestamp)
<$set name="path" value="https://designwritestudio.github.io/resources/sbk/data/$timestamp$/index.html">
Linktext: $linktext$<br>
Timestamp: $timestamp$<br>
Path: <<path>> /><br>
Link: <a href=<<path>> target="new">$linktext$</
a>
</$set>
\end

<$macrocall $name="sbk" timestamp="20161006124512" linktext="test sbk marcro"/
>



(The desired solution, of course, is to transclude the value of path from another tiddler)(but one step at a time).

I generate the link in the debug "path" line, and the link is present in the macrocall, but requires me to right-click/open in new tab to activate. Is  there some special potion available that will let me transclude the desired path into the link structure?

Here is the live wiki: https://designwritestudio.github.io/experimental/scrapbook-interface/scrapbook-tiddlywiki.html


Thanks for any help!

//steve.

Thanks!

//steve.

Jed Carty

unread,
Nov 15, 2016, 4:47:18 PM11/15/16
to TiddlyWiki

Mark S.

unread,
Nov 15, 2016, 5:22:19 PM11/15/16
to TiddlyWiki
I don't understand what you want do do. The macro seems to work fine. You say you're trying to transclude a value from somewhere, but I don't see anywhere that you attempt transclusion.

If you're trying to pull in the contents of the external web site ... I'm not sure if that will work. You might try setting up an iframe instead of an anchor tag sourced from the external site. This iframe seems to work though it needs to be tweaked for usability:

Frame:  <iframe src=<<path>> ></iframe>

Good luck!
Mark

Steven Schneider

unread,
Nov 15, 2016, 8:46:34 PM11/15/16
to TiddlyWiki
OK, then, my macro does seem to work (when I tried it in tiddlywiki.com). I must have a browser issue (firefox), or some sort of corruption in the wiki I was building it in. Thanks! 

stevesuny

unread,
Nov 16, 2016, 12:20:11 PM11/16/16
to TiddlyWiki
I'm back, same macro, different question.

Here is my code, that works:

\define sbk(linktext,timestamp)
<$set name="path" value="https://designwritestudio.github.io/resources/sbk/data/$timestamp$/index.html">
<a href=<<path>> target="_blank">$linktext$</a>
</
$set>
\end

How do I replace the portion of <<path>> that contains "https://designwritestudio.github.io/resources/sbk/data/" with a transcluded tiddler whose text field contains that value?

Thanks!

//steve.



Mark S.

unread,
Nov 16, 2016, 12:47:19 PM11/16/16
to TiddlyWiki
This seems to work (macro and invocation):

\define sbk(linktext,timestamp,path)
<$set name="path" value="$path$$timestamp$/index.html">

<a href=<<path>> target="_blank">$linktext$</a>
</
$set>
\end

<$macrocall $name="sbk" timestamp="20161006124512" linktext="test sbk marcro" path={{mypath}}
/>

Mark S.

unread,
Nov 16, 2016, 1:01:32 PM11/16/16
to TiddlyWiki
This version and invocation assumes you always want to use a tiddler to define the base path:

\define fullpath() $(base)$$(timestamp)$/index.html

\define sbk(linktext,timestamp,path)
<$set name="base" value={{mypath}}>
<$set name=timestamp value="""$timestamp$""">
<$set name="path" value=<<fullpath>>>

<a href=<<path>> target="_blank">$linktext$</a>
</
$set>
</$set>
</
$set>

\end

<$macrocall $name="sbk" timestamp="20161006124512" linktext="test sbk marcro"
/>


On Wednesday, November 16, 2016 at 9:20:11 AM UTC-8, stevesuny wrote:

Steven Schneider

unread,
Nov 17, 2016, 9:53:23 AM11/17/16
to TiddlyWiki
Thanks Mark. I hadn't realized I needed to call "path" in the \define sbk(linktext,timestamp,path) line; that makes perfect sense.
Reply all
Reply to author
Forward
0 new messages