how to display external link from a link stored against an index in a data tiddler

46 views
Skip to first unread message

Ankit Mittal

unread,
Jun 23, 2020, 12:41:35 PM6/23/20
to TiddlyWiki
Hi,

  • I created a form with a field that accepts a URL like https://www.google.com 
  • I then saved this data against an index
  • With edit / save toggle I then switch to view widget
I was hoping to display the data "https://www.google.com" as a link but it just shows it as plain text.

What do I need to do to make it appear as a link?

\define db() $(currentTiddler)$-db
\define dbformstate() $(currentTiddler)$-formstate


<!-- Editable Form -->

<$reveal type="nomatch" stateTitle=<<dbformstate>> stateIndex="form1" text="show">
     <table>
        <tr>
                   <td>
                           <$button type="button" class="btn btn-danger" setTitle=<<dbformstate>> setIndex="form1"  setTo="show">Edit</$button>
                           </td>
                  <td>

|thead-success|k
|Title|Value|h
|!URL Field |<$view tiddler=<<db>> index="dt_URI"/>|

                        </td>
          </tr>
  </table>
</$reveal>

<$reveal type="match" stateTitle=<<dbformstate>> stateIndex="form1" text="show">
       <table>
        <tr>
                   <td>
                           <$button type="button" class="btn btn-success" setTitle=<<dbformstate>> setIndex="form1" setTo="hide">Save</$button>
                   </td>
                  <td>

|thead-danger|k
|Title|Value|h
|!URL Field |<$edit-text tag=input type=url tiddler=<<db>> placeholder="https://" index="dt_URI"/>|

                        </td>
          </tr>
  </table>
</$reveal>



Eric Shulman

unread,
Jun 23, 2020, 1:02:09 PM6/23/20
to TiddlyWiki
On Tuesday, June 23, 2020 at 9:41:35 AM UTC-7, Ankit Mittal wrote:
With edit / save toggle I then switch to view widget
I was hoping to display the data "https://www.google.com" as a link but it just shows it as plain text.
What do I need to do to make it appear as a link?

Instead of writing
<$view tiddler=<<db>> index="dt_URI"/>

You can write:
<$tiddler tiddler=<<db>>>{{##dt_URI}}</$tiddler>

The $tiddler widget sets the context to the title produced by the macro (e.g., $(currentTiddler)$-db).
Then, the {{...}} transclusion uses "##" to retrieve the dt_URI index value.

You could also achieve the same results with a macro that combines the two steps:
\define showlink() {{$(currentTiddler)$-db##dt_URI}}
which you would invoke using
<<showlink>>

enjoy,
-e

Ankit Mittal

unread,
Jun 23, 2020, 1:52:46 PM6/23/20
to TiddlyWiki
Thanks that worked... :)
Reply all
Reply to author
Forward
0 new messages