Hi everyone,

as Kev was asking here [1] how to embed some fancy google code to embed a 
custom search, I went a different road. Hopefully, achieving the same 
desired outcome.

So, here's what I did: Allow the user input his search term(s) and open a 
new window with the constructed search URL.

So, in order to get any desired number of custom google search boxes 
working in a TiddlyWiki, here's what you do:

A) Create a tiddler, perhaps called *[[Google Search]],* containing:
<html>
<span class="g-search">
<input class="g-search-input" type="text" id="$1"/>
<input class="g-search-button" type="button" value="search" 
onclick="javascript:
  var el = document.getElementById('$1');
  window.open('http://www.google.com/cse?cx=$1&q='+el.value, '_blank');
  window.focus();
"/>
</span>
</html>

B) Now you can embed your desired search box in any tiddler using 
transclusion:
<<tiddler "Google Search" with: "YourCustom:SearchId">>

So, what is going on here?

For one, the *[[Google Search]]* tiddler is plain html with a button having 
an onclick handler, so it does something when you click it. In this case, 
open a new window in order to perform a custom google search.

When TiddlyWiki outputs the *[[Google Search]]* tiddler - when it renders 
the tiddler where you have embedded it - it substitutes every occurence of 
$1 in the html snippet with whatever you passed as the first parameter to 
the <<tiddler>> macro. Likewise it would substitute any $2 with a second 
parameter, if there was any.

Finally, if you want the thing to look pretty, you can make use of the css 
classes in your StyleSheet tiddler.

Cheers, Tobias.


[1] 
https://groups.google.com/forum/?fromgroups=#!topic/tiddlywiki/badQG8RBGMM

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to