[TW5] Including Parameters in a URL

133 views
Skip to first unread message

Jonnan

unread,
Jun 22, 2015, 1:13:05 PM6/22/15
to tiddl...@googlegroups.com
I'm probably missing something obvious here.

Okay -  I want to autocreate a link to google the Wiki subject - e.g. https://www.google.com/search?q={{!!title}} where the Title is 'XCOM - Enemy Unknown', thus generating https://www.google.com/search?q=XCOM%20-%20Enemy%20Unknown

Despite attempts with transclusion and a few tricks with escaped characters et al, I'm not coming up with a way to do this within a URL. Am I missing something obvious, or am I just not the bright monkey I think I am?
   
Thanks - Jonnan

Eric Shulman

unread,
Jun 22, 2015, 2:18:57 PM6/22/15
to tiddl...@googlegroups.com
On Monday, June 22, 2015 at 10:13:05 AM UTC-7, Jonnan wrote:
Okay -  I want to autocreate a link to google the Wiki subject - e.g. https://www.google.com/search?q={{!!title}} where the Title is 'XCOM - Enemy Unknown', thus generating https://www.google.com/search?q=XCOM%20-%20Enemy%20Unknown
Despite attempts with transclusion and a few tricks with escaped characters et al, I'm not coming up with a way to do this within a URL. Am I missing something obvious, or am I just not the bright monkey I think I am?

You need to use a macro to construct the desired URL.  Something like this should do:

\define googurl()
 https
://www.google.com/search?q=$(subject)$
\end
<$set name="subject" value={{!!title}}>
<a href=<<googurl>>> click me! </a>
</
$set>

enjoy,
-e
Eric Shulman
ELS Design Studios
TiddlyTools - "Small Tools for Big Ideas!"
InsideTiddlyWiki: The Missing Manuals

YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:

Jonnan

unread,
Jun 22, 2015, 2:31:30 PM6/22/15
to tiddl...@googlegroups.com
Thanks - I was working my way towards that, but was going to be annoyed at myself if there was a quick easy solution I was just missing - <G>.

Måns

unread,
Jun 22, 2015, 2:58:54 PM6/22/15
to tiddl...@googlegroups.com
Hi Jonnan and Eric

I came up with an answer - then I saw Eric had replied already. My example gives you two different macros.
First one is pretty simple as all it does is to create a "pretty link" which points to an url wich is constructed from an URL and a word (or several)

Second macro takes the first macro and injects the prefix url for a google search and <<currentTiddler>> as the search item/subject.

A solution for inputting current tiddler's title into an existing macro seems to be that you "spell out" the macrocall widget to be able to use <<currentTiddler>> - <<<< ... >>>> is a no go...

Ps:Eric's or my macro will work in other tiddlers if you tag the tiddler (with the macro definition) with: $:/tags/Macro

\define gs(url,item)
[[$item$|$url$$item$]]
\end
\define gsl()
<$macrocall $name="gs" url="https://www.google.com/search?q=" item=<<currentTiddler>>/>
\end
Search for <<gs "https://www.google.com/search?q=" "dolphin">>
Search for this tiddlers title <<gsl>>
Cheers Måns Mårtensson

PMario

unread,
Jun 22, 2015, 3:04:41 PM6/22/15
to tiddl...@googlegroups.com
A slightly different approach:

create a tiddler named eg: search

\define searchLink()
https://www.google.com/search?q=$(currentTiddler)$
\end

<a href=<<searchLink>>>search: <<currentTiddler>> </a><br>


remove the <br>, if you don't need it
In a different tiddler call it like this:

{{!!title||search}}

or

{{{[tag[myTag]]||search}}}


related links: http://tiddlywiki.com/#Transclusion:Transclusion%20[[Transclusion%20in%20WikiText]]%20TextReference

have fun!
mario

Jonnan

unread,
Jun 22, 2015, 3:11:51 PM6/22/15
to tiddl...@googlegroups.com
For those scoring at home - Yep, drop it in a Template Tiddler and it works great.

Thank you kindly sir,
Jonnan


On Monday, June 22, 2015 at 2:18:57 PM UTC-4, Eric Shulman wrote:
Reply all
Reply to author
Forward
0 new messages