link to external url with param problem

95 views
Skip to first unread message

ara...@gmail.com

unread,
Dec 25, 2014, 2:10:43 AM12/25/14
to tiddl...@googlegroups.com
Hi there,

I have a fixed tiddler in my wiki, lets say "WhereIsMyBook" (his title) and this tiddler has a specific field named  "url".

This url field has a value that could be something like  "assets/mybook.pdf" if my pdf book is stored localy in a subfolder named "assets",

or "http://www.somewhere.com/mybook.pdf" if book is stored elsewhere in the web.

Now i want to make a macro that will create a link to a specific page of my book  e.g <<page 23>>, but i don't know how...

my first attempt was something like this

\define page(p:"1") [ext[$p$|{{WhereIsMyBook!!url}}#page=$p$]]

but this results to a link <a href="{{WhereIsMyBook!!url}}#page=23">23</a>

i tried also other things but had no success... any idea?

Thank you & merry christmas

Tobias Beer

unread,
Dec 25, 2014, 9:40:37 AM12/25/14
to tiddl...@googlegroups.com
String concatenation in macro parameters especially when generating a url is a very common, ubiquitous problem. Once we have a well worded general solution to this recurring problem, I think it well deserves a prominent spot in the macro documentation.

Best wishes, Tobias.

Stratos Aravias

unread,
Dec 25, 2014, 12:54:37 PM12/25/14
to tiddl...@googlegroups.com
yes i know what u mean, i spend a lot of hours for this, hope you come up with a better solution... but till then hocus pocus also works, once you find where it hides...

Merry Christmas

2014-12-25 16:40 GMT+02:00 Tobias Beer <beert...@gmail.com>:
String concatenation in macro parameters especially when generating a url is a very common, ubiquitous problem. Once we have a well worded general solution to this recurring problem, I think it well deserves a prominent spot in the macro documentation.

Best wishes, Tobias.

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/wui6E_fiXcA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Jed Carty

unread,
Dec 25, 2014, 6:34:18 PM12/25/14
to tiddl...@googlegroups.com
I don't know if it will work as a general solution, but this works as part of the contacts things I have at inmysocks.tiddlyspot.com

I am on a phone so I can't really test it in the context of a normal url, but the link works in the contacts stuff. I think the combination of the set widget and the macro is the important part, but I am not certain.



\define getAddress()
mailto:$(address)$
\end

<$set name=address value={{$(tiddlerName)$!!$fieldName$}}>
<a href=<<getAddress>> target="_top">{{$(tiddlerName)$!!$fieldName$}}</a>
</$set>

Tobias Beer

unread,
Dec 26, 2014, 4:05:29 PM12/26/14
to tiddl...@googlegroups.com
Hi Jed,
 
\define getAddress()
mailto:$(address)$
\end

<$set name=address value={{$(tiddlerName)$!!$fieldName$}}>
<a href=<<getAddress>> target="_top">{{$(tiddlerName)$!!$fieldName$}}</a>
</$set>

It very much feels like there is some macro missing for this to make sense... or would you simply use one-liner macro definitions to "set" these variables, e.g.:

\define tiddlerName() foo
\define fieldName() bar

Feels slightly awkward though as I wouldn't know why I can't wrap that macro and call it with the desired parameters,

Tobias.

Jed Carty

unread,
Dec 26, 2014, 5:04:40 PM12/26/14
to tiddl...@googlegroups.com
I am not sure why works, but this I think is something like what the original question is about. It works anyway.

http://inmysocks.tiddlyspot.com/#Make%20url

select the page number using the select widget and then the url will bring you to the selected page.

Jed Carty

unread,
Dec 26, 2014, 8:06:55 PM12/26/14
to tiddl...@googlegroups.com
It looks like it can be a bit simpler by cutting out the second macro in the previous example. http://inmysocks.tiddlyspot.com/#Concatenating%20text%20to%20make%20dynamic%20URLs
Reply all
Reply to author
Forward
0 new messages