how do I inject one code into every tiddler tagged with x

227 views
Skip to first unread message

Sapphireslinger

unread,
Oct 2, 2020, 10:30:07 AM10/2/20
to TiddlyWiki
I have a separate tiddler for each book in my library [example title: Book - J. R. R. Tolkien - The Lord of the Rings] When I'm reading a book, every time I like something, I copy and paste the quote into it's own tiddler and make sure it is tagged with the title of the book tiddler. That way all of a book's quotes show up in its book tiddler since I have this code in each book tiddler:

<$list filter="[tag<currentTiddler>!sort[title]]">
<h2><$link><$transclude field="title" mode="block"/></$link></h2>
<$transclude field="text" mode="block"/>
</$list>

My problem:

I was pasting that code into every single book tiddler until I realized I was needlessly bloating my wiki! If I have a thousand books that would be a thousand extra paragraphs in my wiki.

How do I create just one tiddler that commands all book tiddlers to show that code? Is there just one tiddler I can create that just commands that code show up in every book tiddler? or every tiddler that happens to have the tag "book"?

(P.S. The reason I give so much background on my request, is so newbies can see use cases. Often I see people ask for help with code but I don't know what they are using it for, and so don't know if I would want to use it as well.)

Eric Shulman

unread,
Oct 2, 2020, 10:55:49 AM10/2/20
to TiddlyWiki
On Friday, October 2, 2020 at 7:30:07 AM UTC-7, Sapphireslinger wrote:
How do I create just one tiddler that commands all book tiddlers to show that code? Is there just one tiddler I can create that just commands that code show up in every book tiddler? or every tiddler that happens to have the tag "book"?

Create a tiddler (e.g., "BookQuotes"), tagged with "$:/tags/ViewTemplate", containing:
<$list filter="[<currentTiddler>tag[book]]">
   <$list filter="[tag
<currentTiddler>!sort[title]]">
   
<h2><$link><$transclude field="title" mode="block"/></$link></h2>

   <$transclude field="text" mode="block"/>
   </$list>
</$list>

Notes:
1) The $:/tags/ViewTemplate automatically adds the BookQuotes tiddler content to *every* tiddler
2) The outer $list widget makes the content only appear in tiddlers tagged with "book"
3) The inside of the $list widget is the output to show.... in this case, the code you posted.

By default, the output appears at the bottom of the standard tiddler ViewTemplate output.  You can change the placement of your output by using drag-and-drop inside the $:/tags/ViewTemplate tag pill displayed with <<tag $:/tags/ViewTemplate>>.

enjoy,
-e




Sapphireslinger

unread,
Oct 4, 2020, 7:37:01 AM10/4/20
to TiddlyWiki
Eric,

Thank you very much! Works like a charm!

However, I have the TWcrosslinks plugin, and I am curious why the transcluded quotes show up under those TWcrosslinks as if outside/below the tiddler.

It's not a problem, will probably turn out very convenient even, just curious.

Eric Shulman

unread,
Oct 4, 2020, 7:44:12 AM10/4/20
to TiddlyWiki
On Sunday, October 4, 2020 at 4:37:01 AM UTC-7, Sapphireslinger wrote:
However, I have the TWcrosslinks plugin, and I am curious why the transcluded quotes show up under those TWcrosslinks as if outside/below the tiddler. 
It's not a problem, will probably turn out very convenient even, just curious.

As I noted in my previous post:
 
You can change the placement of your output by using drag-and-drop inside the $:/tags/ViewTemplate tag pill displayed with <<tag $:/tags/ViewTemplate>>.

-e 




arun babu

unread,
Oct 4, 2020, 8:02:48 AM10/4/20
to TiddlyWiki
I have a similar usecase. 

I collect cases and articles published by doctors and make them seperate tiddlers with the name of the case or article as the tiddler's title. I have seperate tiddlers for each doctor also with the doctor's name as that tiddler's title. 

I give seperate tags for the each doctor's tiddler based on whether he/she publish article or case. 
1. if the doctor publishes articles only, he will be tagged with tag 'Authors' only
2. if the doctor publishes cases only, he will be tagged with tag 'Consultants' only
3. if the doctor publishes both articles and cases, he will be tagged with both tags.

For each case/article by a doctor, i use doctor's name as a
 tag. Additionally i add a field for each case/article.
1. if it is an article - 'field name' - 'what' and 'field value' - 'article' is given.
2.  if it is an case - 'field name' - 'what' and 'field value' - 'case' is given.
 
Finally in the tiddler with title of the doctor, I make a list fliter to group the cases and articles under that that doctor seperately. Code i use is given below:

<<tabs tabsList:"[tag[doctors-name]what[case]]" default:"dem/24 news" class:"tc-vertical">>

<<tabs tabsList:"[tag[doctors-name]what[article]]" default:"dem/24 news" class:"tc-vertical">>

Can you suggest how should i modify this code so that it will be automatically added into all doctors tiddlers. I tried to make the code similar to what you suggested in the previous message, but I don't know where to add the field value in that code. Please help.

Similarly I have two tiddlers with title 'Authors' and 'Consultants' in which I need to make a list of the doctors who published articles and cases respectively along with a list of articles/cases under each doctor. I currently TOC code given below for that purpose.

<div class="tc-table-of-contents">
<<toc-selective-expandable "Authors">><<sort by 'title'>>
</div>

<div class="tc-table-of-contents">
<<toc-selective-expandable "Consultants">><<sort by 'title'>>
</div>

But this code will list both cases and articles under each doctor in both 'Authors' and 'Consultants' tiddlers. Can you suggest a better way to list the doctors in Authors and Consultant tiddlers with only their articles or cases being shown depending upon whether its Authors tiddler or Consultants tiddler. 

TW Tones

unread,
Oct 5, 2020, 1:17:00 AM10/5/20
to TiddlyWiki
Like Erics first reply the way to get things to display on a groups of tiddler, not just one is to use a tiddler tagged "$:/tags/ViewTemplate

Then inside that you can have a number of list or reveal widgets that respond to the content of the tiddler eg "[all[current]tag[author]!tag[..."

It you want you can have one view template tiddler with a stack of different conditional display's with as many conditions as you want.

In this case I would not use the tags 'Authors' or `Consultants` just work out which they are when needed, otherwise if you subsequently add/delete an article/or case you need to manage that. Doctors could just list their articles and cases through a view template, and a separate list can list those with one both if they are a  'Authors' or `Consultants`.

I hope this idea is clear.

Tones

arun babu

unread,
Oct 16, 2020, 6:01:12 AM10/16/20
to TiddlyWiki
Thanks Tones for the reply.. I was able to modify content of this code <<tabs tabsList:"" default:"dem/24 news" class:"tc-vertical">> in the tiddler to be tagged with '$:/tags/ViewTemplate' so that the tab list will show up only in the desired tiddlers. 

I have one doubt though. I made a dashboard like tiddler where all these tiddlers with tab lists are grouped using a code <<tabs " " >>. In this dashboard, everything else of those tiddler with tab lists are seen except the listed tabs. The individual tiddlers shows the listed tabs nicely. However, the listed tabs are not seen in the dashboard tiddler. Can you suggest whether something needs to be corrected. I prefer tab list since I can add links to each tab using edit-tabs plug ins to open them seperately.

After going through many posts in this google group, I tried to reduce the number of tags I am using currently and put those variables into the tiddler fields. I even made a custom buttons using action setfiled widget to create 'article' and 'case' tiddlers with fields being set automatically. And making such a button has reduced the amount of time I required to make the tiddlers. 

I have another doubt. I was trying to make a flashcard set up for my wife using Anwiki (a tiddlywiki based Anki like spaced repetition system - http://anwiki.tiddlyspot.com). Since it is not available as a plug in, I had to do some extra work like creating custom buttons to create flashcards from which ever notes tiddler she want to make into flashcard. I made "create flash card button" using actions set field widget with the code given below:

<$button>
<$action-setfield $tiddler="New Card" tags="[[Flash Card]]" question="" answer="" what="Flash Card" />
<$action-sendmessage $message="tm-edit-tiddler" $param="New Card"/>
Create~New Card
</$button>

The newly created flashcard will have a title "New Card", tag "Flash Card" and  two fields for question and answer. ("Flash Card" tag  and fields for "question" and "answer" are required for Anwiki system to work. So I can't modify it). I used '$:/tags/ViewTemplate' to insert this "create flash card button" into tiddlers with field value "Note" for easily converting such notes tiddlers into flashcard tiddlers. 

So the "Flashcard tiddler" should be a child of the "Notes tiddler". I need some help in modifying the code for the "create flash card button" so that the title, tags, question and answer fileds of the flash card tiddler is automatically filled up. 

I need the title of the child tiddler (Flash Card) to be a modified version of the parent tiddler (Notes tiddler) - for example if the title of the notes tiddler is "Types of uveitis", the title of the Flash Card should be "f: Types of uveitis". This is just an example. It can be something else also, but a modified version of the parent tiddler"s title. The field named "question" should have a field value same as the "title of the flashcard(child) or notes(parent) tiddler".  The field named "answer" should have a field value which will be the transcluded notes tiddler - {{Notes/Parent tiddler title}}Can you provide some help.

I know this can be manually done. But since my wife won't be comfortable with so much copy pasting while making flash cards, it will be easier for her if I create such a custom button.

I also had a look at Flippy Cards https://tid.li/tw5/test/flippy.html, but it not working with the current TW version.
 

Reply all
Reply to author
Forward
0 new messages