Mechanism to select a tiddler and transclude its contents

161 views
Skip to first unread message

Huw

unread,
Mar 23, 2019, 4:35:26 AM3/23/19
to TiddlyWiki
Hello. Iv been an on and off user of TW since the early days and I'm just starting out with TW5.

What I want to do (any advice or re-direction is fine)

Create a list from a specific tag
This can be in any format (For example just a list of tiddlers or the same list inside a select control etc)

Transclude selected Tiddler into a panel on the same page
When I click a tiddler in the list the content of the tiddler needs to be transcluded into a DIV or some other kind of container that is on the same page as the list and preferably editable.

Actual Objective
I am a part time author and as such I have a huge collection of stories and story notes. I also have a Character editor and this is what I am working on. I need a list of tiddlers with the 'Character' tag, and when clicking on one I want the content of that Character tiddler displayed in some kind of container on the same page as the list.

Of course the same tiddlers can be opened normally from within any body of text, but this is where the collection of Characters lives and I want to be able to create and edit them there.

What I don't want 
Tiddlers appearing in an iFrame with the sidebar menu etc. I want just the content of the tiddler to be seen

What Iv already done
So far Iv only managed to get a list of tiddlers with the correct tag, but I am entirely at a loss as to how to transclude a selected tiddler into another part of the page based on the item click in the list. I simply don't know where to start.

By all means correct any assumptions Iv made incorrectly and point me in the right direction (If this is possible at all)

Kind regards

Huw

S. S.

unread,
Mar 23, 2019, 8:00:21 AM3/23/19
to TiddlyWiki
Perhaps a Tabbed Internal Table of Contents could satisfy the first half of your requirement, viewing the tiddlers.

Make a tiddler:
title:My Character List
text:
<$macrocall
    $name="toc-tabbed-internal-nav"
    tag="Character"
    selectedTiddler="$:/temp/toc/My Character List"
    unselectedText="
<p>Select a topic in the table of contents. Click the arrow to expand a topic.</p>"
    missingText="
<p>Missing tiddler.</p>"
/>

Save the tiddler and you have your list of characters on the left, and clicking the link opens the TEXT of the tiddler on the right.

Now we have to figure out how to make them editable - I believe Mark S. has shown something similar somewhere.

Eric Shulman

unread,
Mar 23, 2019, 11:31:13 AM3/23/19
to TiddlyWiki
On Saturday, March 23, 2019 at 1:35:26 AM UTC-7, Huw wrote:
Create a list from a specific tag
This can be in any format (For example just a list of tiddlers or the same list inside a select control etc)

Transclude selected Tiddler into a panel on the same page
When I click a tiddler in the list the content of the tiddler needs to be transcluded into a DIV or some other kind of container that is on the same page as the list and preferably editable.

Give this a try:
<$select tiddler="$:/temp/selected/character">
   <$list filter="[tag[About]]">
     
<option><$text text=<<currentTiddler>> /></option>
   </$list>
</$select>
<br>
<style>.wideEdit { width:100%; } </style>
<$edit-text tiddler={{$:/temp/selected/character}} tag="textarea" class="wideEdit" autoHeight="no" rows="15" />


What it does:
* The $select widget creates a drop-down list of all the titles matching the tag value (in this example, "About")
* The current selection is stored in a temporary tiddler, "$:/temp/selected/character" (note: you can use any tiddler title you like)
* The embedded <style> defines a classname for setting the edit field width (you can't use a style attribute directly in the $edit-text widget)
* The name of the target tiddler title used by $edit-text is retrieved from the temporary tiddler
* The remaining $edit-text parameters control how the edit field looks/behaves

Note: unlike the usual tiddler editor "draft mode", the $edit-text field used here is *LIVE*... that is, changes to the content are applied immediately to the underlying tiddler... there is no "ok/cancel" or "undo" functionality.

Let me know how it goes...

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki: The Missing Manuals

 

Mohammad

unread,
Mar 23, 2019, 11:47:04 PM3/23/19
to TiddlyWiki
Added to TW-Script

Huw

unread,
Mar 24, 2019, 4:50:55 AM3/24/19
to TiddlyWiki
Hey guys, thanks for the replies - its good to hear that this is actually possible.

Eric: Your code works nicely however the tiddlers (Characters) that are displayed are shown in raw text format rather than the nicely formatted tiddlers that I have set up. Is there some way to display them as actual tiddlers rather than in their raw text state?

Birthe C

unread,
Mar 24, 2019, 8:32:58 AM3/24/19
to TiddlyWiki
Hi Huw,

That is because you asked to be able to edit the selected tiddler. If you only want to view them you could transclude the tiddler.


Birthe

Huw

unread,
Mar 24, 2019, 8:51:55 AM3/24/19
to TiddlyWiki
Okay, fair enough, perhaps I didn't think that through when I was typing! So how would I transclude the tiddler in the same way?

Thanks, Huw

Birthe C

unread,
Mar 24, 2019, 9:33:26 AM3/24/19
to TiddlyWiki
Replace the edit part with <$transclude tiddler={{$:/temp/selected/character}}/>


Birthe

Huw

unread,
Mar 24, 2019, 4:33:04 PM3/24/19
to TiddlyWiki
Ah! Thats excellent thanks!

Ill have to tinker a little with my Character files because I use "$view field" for names and such because of the way I create the files (I use a template and a button/input field combo to take a name and generate the character file). Aside from that it works exactly as I wanted it to!

Many thanks to everyone who chipped in!

Regards
Huw
Reply all
Reply to author
Forward
0 new messages