[TW5] Wikitext: using Transclusion as Link Target

639 views
Skip to first unread message

Alex H

unread,
Jan 6, 2016, 6:07:04 AM1/6/16
to tiddl...@googlegroups.com
Hey guys,

I think I'm pretty close to a solution here, but I can't figure it out...

Short problem description:

I want to make a link to a tiddler where the target is the content of another tiddler.
So let's say I have the tiddler named "A" with content "B" and I have a tiddler named "B" with some content. As you might have noticed the title/name of tiddler "B" is equivalent to the content of the tiddler "A".
So, I'd like to link to tiddler B by doing something like this:
[[ a link to tiddler B|{{A}}]]

Clicking on that link results in "Missing tiddler "{{A}}" - click to create" - so the transclusion isn't resolved.

Any thoughts?



Long problem description:

There is a good chance that I'm going on this problem the wrong way, so let me explain what I'm trying to do:

I have a Table of Contents Tiddler, as described here http://tiddlywiki.com/static/Example%2520Table%2520of%2520Contents%253A%2520Tabbed%2520Internal.html

I use this tiddler quite often to browse around and do some quick lookups. And for these quick lookups the internal view is great, but sometimes I want the tiddler I'm looking at in a separate tiddler (for later use or open up multiple tiddlers side by side).

The title of tiddler I'm looking at the moment is in "$:/temp/toc/selectedTiddler", so what I'm trying to do is simply add a link at the bottom of the Table of Contents Tiddler which opens the content of "$:/temp/toc/selectedTiddler" in a seperate tiddler.
I'm trying to do this like so:

[[Click to open current tiddler sepreately |{{$:/temp/toc/selectedTiddler}}]]


But the same problem as above occurs...


I'm happy for any ideas...
Thanks

Edit: I just noticed the
Example Table of Contents: Tabbed Internal on the static tiddlywiki page does not work the same way as on the original page.
So, in order to better understand my scenario, please go to tiddlywiki.com and search for Example Table of Contents: Tabbed Internal.

Edit 2: haha, I just by accident posted the link the the dynamic page of tiddlywiki - did not know you can link there ;-)


Tobias Beer

unread,
Jan 6, 2016, 9:04:30 AM1/6/16
to TiddlyWiki
Hi Alex,

I want to make a link to a tiddler where the target is the content of another tiddler.

You need a helper macro used as:

<<defer "foo!!bar" "pretty title">>

The macro...

title: $:/.tb/macros/defer
tag
: $:/tags/Macro

\define deferred(title,pretty)
<$reveal type="nomatch" text="""$pretty$""" default="">
[[$pretty$|$title$]]
</$reveal>
<$reveal type="match" text="""$pretty$""" default="">
[[$title$]]
</$reveal>
\end

\define defer(title,pretty)
<$macrocall $name="deferred" title={{$title$}} pretty="""$pretty$"""/>
\end

Best wishes,

Tobias.

Tobias Beer

unread,
Jan 6, 2016, 9:27:40 AM1/6/16
to TiddlyWiki
Hi Alex,
 
I want to make a link to a tiddler where the target is the content of another tiddler.

Now to the really interesting question: Why do you want to do that?

Best wishes,

Tobias. 

Alex H

unread,
Jan 6, 2016, 12:04:59 PM1/6/16
to TiddlyWiki

Wow, seems like I wasn't so close to a solution after all ;-)
Thanks a lot this works perfectly!!! Crazy stuff!


Now to the really interesting question: Why do you want to do that?

Well, I'm using a tiddler with a "tabbed internal - Table of Contents" ( http://tiddlywiki.com/#Example%20Table%20of%20Contents%3A%20Tabbed%20Internal ) quite often (it's actually my home tiddler).
Most of the time I just browse a little bit, take a quick look at a tiddler, do some work and browse to a other tiddler within this home tiddler of mine.
But sometimes I want the currently active tiddler of this home tiddler opened individually.
So, not inside the table of content tiddler, but opened as a normal tiddler, so I can look at multiple tiddlers at the time.
And with your awesome helper macro my Table of Content home tiddler looks now like this:
<$macrocall
    $name="toc-tabbed-internal-nav"
    tag="Contents"
    selectedTiddler="$:/temp/toc/selectedTiddler"
    unselectedText="
<p>Select a topic in the table of contents. Click the arrow to expand a topic.</p>"
    missingText="
<p>Missing tiddler.</p>"
/>
<
<defer "$:/temp/toc/selectedTiddler" "open current tiddler seperatly">>


So, it's now just one click and the current active internal tiddler gets opened as an external tiddler.

I'm pretty sure I messed up some of the terminology, but I still hope it's clear what I mean.


Thanks again!!!

Tobias Beer

unread,
Jan 6, 2016, 3:22:25 PM1/6/16
to TiddlyWiki
Hi Alex,
 
But sometimes I want the currently active tiddler of this home tiddler opened individually.

There are two things I am wondering now:
  1. If there is any way to define a custom template that contains a link
    from a tiddler in an internal toc to have it open in the main story river.
  2. What needs to be done so we can have default (horizontal) tabs
    where clicking a link inside one opens the tiddler as a tab, if it is a tab,
    similar to how the toc keeps things "internal".
Best wishes,

Tobias.

Eric Shulman

unread,
Jan 6, 2016, 4:42:21 PM1/6/16
to TiddlyWiki
The toc-tabbed-internal macro works by wrapping the tabs in a <$linkcatcher> widget that takes the link target and sets the selectedTiddler ($:/temp/toc/selectedTiddler).  This, in turn, triggers a refresh of the tab display area which transcludes the current selectedTiddler.

Perhaps there is a way for a link that is contained within a <$linkcatcher> to force it's way out; however, as far as I know, anything that produces a tm-navigate message will be caught.


-e

Jed Carty

unread,
Jan 6, 2016, 4:49:27 PM1/6/16
to TiddlyWiki
Tobias,

I am not sure what you mean by 1, but I really like the idea of 2. I think that it could be done without too much trouble if we allow either the link or link catcher widget to trigger action widgets, or if you make fake links with buttons. However you do it, the action-listops widget could add which ever link is click to a list field and the list could be used as the filter to define the tabs using a normal tabs macro.
We would have to modify the macro a bit to add a close button to each tab but I think that some sort of advanced tabs macro like that would get used a lot. Something like the breadcrumbs Ton Gerner made (http://tw5breadcrumbs.tiddlyspot.com/), but with tabs.

Tobias Beer

unread,
Jan 6, 2016, 5:27:05 PM1/6/16
to TiddlyWiki
Hi Jed,
 
We would have to modify the macro a bit to add a close button to each tab but I think that some sort of advanced tabs macro like that would get used a lot. Something like the breadcrumbs Ton Gerner made (http://tw5breadcrumbs.tiddlyspot.com/), but with tabs.

All this sounds a lot like we're on our way to a TiddlersBar for TW5.

Best wishes,

Tobias.
Message has been deleted

grundyunderhill

unread,
Dec 10, 2016, 1:54:59 AM12/10/16
to TiddlyWiki
Hi all,
Not sure whether anyone is still following this thread; if so, maybe you'll find this interesting.

Ton Gerner was kind enough to point me here, in response to a question I posed a few days ago, essentially looking to do same thing as Alex -- create a link to open the current tiddler from a toc-tabbed-internal-nav into the main story river.  I envisioned it being part of a template tiddler, but couldn't figure out how to override the link-trapping functionality of the macro.

Based on the conversation here, though, I gleaned enough knowledge to do something just as cool: an adapted version of the macro with the "break out" link built into the right-hand pane.  In short, I've borrowed Tobias' solution for creating the link, and paired it with a tweaked copy of the toc-tabbed-external-nav macro.

toc-tabbed-external-nav became the basis because that's where the two-pane structure is defined -- toc-tabbed-internal-nav simply wraps a call to this with a <$linkcatcher> widget.  My tweak places <$linkcatcher> directly around transcluded content within the right-hand pane instead, so that additional links, etc may be added outside the <$linkcatcher> but still within the pane.  So altogether we have this:

\define tocTools( to )
@@.tocTools
<$button to="$to$">{{$:/core/images/link}}</$button>
<$button to="$to$" message="tm-edit-tiddler">{{$:/core/images/edit-button}}</$button>
@@
\end

\define smokeMirrors( selected )
<$macrocall $name="tocTools" to={{$selected$}}/>
\end

\define toc-tabbed-internal-nav-gu( tag, sort:"", selectedTiddler:"$:/temp/toc/selectedTiddler", unselectedText, missingText, template:"" )
<$tiddler tiddler={{$selectedTiddler$}}>
  <div class="tc-tabbed-table-of-contents">
    <$linkcatcher to="$selectedTiddler$">
      <div class="tc-table-of-contents">
        <$macrocall $name="toc-selective-expandable" tag="""$tag$""" sort="""$sort$""" itemClassFilter=<<toc-tabbed-selected-item-filter selectedTiddler:"""$selectedTiddler$""">>/>
      </div>
    </$linkcatcher>
    <div class="tc-tabbed-table-of-contents-content">
      <<smokeMirrors $selectedTiddler$>>
      <$linkcatcher to="$selectedTiddler$">
        <$reveal state="""$selectedTiddler$""" type="nomatch" text="">
          <$transclude mode="block" tiddler="$template$">
            <h1><<toc-caption>></h1>
            <$transclude mode="block">$missingText$</$transclude>
          </$transclude>
        </$reveal>
        <$reveal state="""$selectedTiddler$""" type="match" text="">
          $unselectedText$
        </$reveal>
      </$linkcatcher>
    </div>
  </div>
</$tiddler>
\end

...which provides both "navigate" and "edit" links for the current tiddler as buttons.  The .tocTools style wrapping the buttons can be defined however you like, of course.  I have them floating right, with a small top margin to put some space between them and the pane border.

Muchos gracias, Tobias and Eric, for the hints about deferred linking and the macros' use of <$linkcatcher>.  Hope my take on the solution will be helpful to someone too.  Maybe one of these days I'll package it up as a plug-in...

Mat

unread,
Dec 11, 2016, 8:52:28 AM12/11/16
to TiddlyWiki
@grundyunderhill
Thanx for sharing but forgive my dull brain - could you please post an actual example of this?
To simplify for you, I put up this on tiddlyspot (password: password) which includes some dummy tiddlers tagged "tag1".
Would be appreciated.

<:-)
Reply all
Reply to author
Forward
Message has been deleted
0 new messages