Transclusion issues

239 views
Skip to first unread message

Bob Jansen

unread,
Oct 5, 2020, 2:05:50 AM10/5/20
to TiddlyWiki
I am trying to implement a simple function in my TW.

<code>
<$button>
<$list filter="[tag[Mark]]">
     <!--append exhibition_id to exhibition_id of each marked artwork tiddler-->
     
           <$action-setfield 
               $field="exhibition_id" 
               $value={{{ [{!!exhibition_id}addsuffix[ ]addsuffix{$:/TLS/exhibition_id}] }}}
          />
   
     <!--append each artwork_id to artwork_id of the exhibition tiddler-->
     
          <$action-setfield 
               $tiddler= {{{ [{$:/TLS/exhibition_id}] }}}
               $field="artwork_id" 
               $value={{{ [{$:/TLS/exhibition_id!!artwork_id}addsuffix[ ]addsuffix{$:/TLS/artwork_id}] }}}
          />
     
</$list>

Link Artworks to Exhibition
</$button>
</code>

The first action-setfield works. The second one doesn't but I can not determine why. It differs from the first in that the first is editing a field of the <currentTiddler> from a $list widget whilst the second is editing a field of a tiddler whose title is stored in the tiddler $:/TLS/exhibition_id.

Is it possible to edit a tiddler not part of the $list widget set?

To my understanding, there are essentially two transclusions involved, first to get to the tiddler whose title is in $:/TLS/exhibition_id and the second to the field artwork_id stored in this tiddler.

From Tones' excellent cheat sheet, I thought I has it right but obviously not. 

There is obviously an error in my wikitext. But what??

Secondly, an earlier query regarding conditional operators with some advice from Saq Imtiaz.

I want to only perform the action-setfield if the value to be inserted is not already in the field.

I thought this would work (replacement for the first action-setfield statement from above).
<code>
     <$list [{!!exhibition_id}!contains{$:/TLS/exhibition_id}]  variable="_null" >
           <$action-setfield 
               $field="exhibition_id" 
               $value={{{ [{!!exhibition_id}addsuffix[ ]addsuffix{$:/TLS/exhibition_id}] }}}
          />
     </$list>
</code>
 but it doesn't.

What an I doing wrong here?

bobj

TW Tones

unread,
Oct 5, 2020, 3:10:48 AM10/5/20
to TiddlyWiki
Bob,

I have not seen a fault yet, I will keep looking, however when adding items to a list consider using the ActionListops widget rather than adding suffixes. It has the advantage of not setting it twice etc...

Your second attempt at the first action set field will store each tiddler tagged Mark in _null thus current tiddler will be the currentTiddler running when you click the button.

When debugging buttons 
  • you can make large buttons by displaying an intermediate result as the button title to see the output.
  • Your can also make the same loop as just a list, and text what your logic generated before you hide it with actions tiddlers when don't themselves present output, just actions.
<$list filter="[tag[Mark]]">
     
<!--append exhibition_id to exhibition_id of each marked artwork tiddler-->

     
           action-setfield
               $field="exhibition_id"
               $value={{{ [{!!exhibition_id}addsuffix[ ]addsuffix{$:/TLS/exhibition_id}] }}}
               `{{{ [{!!exhibition_id}addsuffix[ ]addsuffix{$:/TLS/exhibition_id}] }}}`
           
   
     
<!--append each artwork_id to artwork_id of the exhibition tiddler-->
     
          action-setfield
               $tiddler= {{{ [{$:/TLS/exhibition_id}] }}}
               $field="artwork_id"
               $value={{{ [{$:/TLS/exhibition_id!!artwork_id}addsuffix[ ]addsuffix{$:/TLS/artwork_id}] }}}
               `{{{ [{$:/TLS/exhibition_id!!artwork_id}addsuffix[ ]addsuffix{$:/TLS/artwork_id}] }}}`
         
     
</$list>

See how I replicated the tripl braces, keep both upto date as you test you outcomes
  • I basically converted the otherwise actions into text and took it outside of the button.
Regards
Tony

Joshua Fontany

unread,
Oct 5, 2020, 7:26:49 PM10/5/20
to TiddlyWiki
One problem here is that the code inside of the $button, including your $action widgets, are parsed/rendered once when the Button itself is displayed, and will not be updated as the underlying Wiki tiddlers change (for example, once that Button is onscreen, changes to the list of Tagged tiddlers will not be picked up).

In order to work around this, it is recommended that you pass all actions that need complex wikitext to a button as-a-macro-parameter to the "actions" parameter. This causes the wikitext in the actions block to be parsed and "rendered" at the time the button is clicked. Like so:

\define buttonActions()
<$list filter="[tag[Mark]]">
     <!--add global exhibition_id to the exhibition_id list-field of each marked artwork tiddler-->
     <!--$listops $subfilter will append any new filter run to the existing list-field-->
           <$action-listops
               $field="exhibition_id" 
               $subfilter="[{$:/TLS/exhibition_id}]"
          />
   
     <!--append each artwork_id to artwork_id list-field of the exhibition tiddler-->
          <$action-listops
               $tiddler= {{{ [{$:/TLS/exhibition_id}] }}}
               $field="artwork_id" 
               $subfilter="[{$:/TLS/artwork_id}]"
          />
     
</$list>
\end

<$button actions=<<buttonActions>> >
Link Artworks to Exhibition
</$button>


Best,
Joshua Fontany

Dr. Bob Jansen

unread,
Oct 5, 2020, 7:39:30 PM10/5/20
to tiddl...@googlegroups.com
Thanks Tones and Joshua for your feedback. I will investigate what you have advised and hopefully this will fix things. Joshua, I was not aware of the timing issue you mentioned. Have not come across that as yet but will keep that in mind from now.

thank again

bobj
--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/ade9rEZzuPg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/9bf12d31-1e8d-494f-96cd-ce937d9ef9a0n%40googlegroups.com.

-- 
--------------------------------
Dr Bob Jansen
122 Cameron St, Rockdale NSW 2216, Australia
Ph (Korea): +82 10-4494-0328
Ph (Australia) +61 414 297 448
Resume: http://au.linkedin.com/in/bobjan
Skype: bobjtls
KakaoTalk: bobjtls
http://cultconv.com

In line with the Australian anti-spam legislation, if you wish to receive no further email from me, please send me an email with the subject "No Spam"

Bob Jansen

unread,
Oct 6, 2020, 12:26:17 AM10/6/20
to TiddlyWiki
Tones,

just had a go at your suggestion. What a wonderful way to see what is happening. I can now see how I get the result I get but not why. Still, another step forward. This mechanism should be written up in the documentation! Now to work out why.

bobj

Bob Jansen

unread,
Oct 6, 2020, 12:34:43 AM10/6/20
to TiddlyWiki
Joshua,

just tried your suggestion. MIxed result.

The test was:

artworks marked TK17 and TK19
exhibition selected TK21

The first action-listops worked as the action-setfield did before, TK21 added to the exhibition_id field of both TK17 and TK19. 

The second action-listops worked better, only one instance of TK19 added to the artwork_id of TK21 but TK17 missing. I my code, I would have seen two TK19's in the field so the action-listops means I don't need the 'contains' list operator.

$:/TLS/artwork_id is set to TK19 but maybe the second action-listops is not being performed until both artwork tiddlers have been processed through the first action-listops.

Still onward and upward.

bobj
Message has been deleted

Bob Jansen

unread,
Oct 6, 2020, 5:03:38 PM10/6/20
to TiddlyWiki
Hi Brains Trust, I need your combined knowledge.

I have uploaded a copy of my TW to http://cultconv.com/TLSConsignment.html

I have implemented Joshua's suggestions, from above, in the tiddler, Link artworks to exhibition Joshua. I have added two action-log messages to trace processing.

Artworks marked are TK17, TK18 and TK19.

If I select TK15 from the popup list, $:/TLS/exhibition_id tiddler is set to TK15

Now, on clicking the button to start the process, the dev console shows the following trace:

artwork_id TK17
exhibition_id TK19
artwork_id TK18
exhibition_id TK19
artwork_id TK19
exhibition_id TK19

Nowhere is TK15 displayed

TK15 has its artwork_id set to TK19 and only TK19, no TK17 nor TK18.

Can anyone explain this?

bobj

TW Tones

unread,
Oct 6, 2020, 5:47:27 PM10/6/20
to TiddlyWiki
Bob,

I had a quick look, I am busy this morning

The only issue I detected so far is in the debug view onscreen I see the value had leading spaces, I corrected this with the trim[] at the end of the filters in the actions widgets for example

{{{ [{!!exhibition_id}addsuffix[ ]addsuffix{$:/TLS/exhibition_id}trim[]] }}}

I can look later in the day, but do share a supposed to work and a debug view if possible.

Tones

Dr. Bob Jansen

unread,
Oct 6, 2020, 6:38:11 PM10/6/20
to tiddl...@googlegroups.com
Tones,

Thank you for your reply.

I think you are looking at the wrong wikitext. I am focusing on Joshua's suggestion, implemented in the tiddler, Link artworks to exhibition Joshua. This implements your suggestion about using action-listops instead of addsuffix which, because it seems to check for duplicates, makes for simpler wikitext. Have a look at the TW I uploaded, http://cultconv.com/TLSConsignment.html to see the latest version.

bobj
--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/ade9rEZzuPg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.

Saq Imtiaz

unread,
Oct 6, 2020, 7:30:11 PM10/6/20
to TiddlyWiki
\define buttonActions()
<$list filter="[tag[Mark]]">
     
<!--add global exhibition_id to the exhibition_id list-field of each marked artwork tiddler-->
     
<!--$listops $subfilter will append any new filter run to the existing list-field-->
           
<$action-listops
               $field
="exhibition_id"
               $subfilter
="[{$:/TLS/exhibition_id}]"
         
/>


<$action-log message="artwork_id" value={{!!artwork_id}} />

   
     
<!--append each artwork_id to artwork_id list-field of the exhibition tiddler-->
         
<$action-listops
               $tiddler
= {{$:/TLS/exhibition_id}}
               $field
="artwork_id"
               $subfilter={{!!artwork_id}}
         
/>


<$action-log message="exhibition_id" value={{$:/TLS/artwork_id}} />


   
</$list>
\end


This action will link the marked artworks with the selected exhibition.


The list of marked artworks


<$list
     filter="[tag[Artworks]tag[Mark]!<currentTiddler>sort[title]]">
     &bull;
     <$link/
>
     
<$view  field="artwork_title" />
     
<$view field="artwork_type"/>
     
<br/>
</$list>


<!-- the selected exhibition id will be stored in the exhibiton_id field on this tiddler-->
Choose the exhibition from this list:


<$macrocall
     $name="edit-list"
     tiddler="$:/
TLS/exhibition_id"
     listview="
{{{ [<value>get[exhibition_name]] }}}"
     filter="
[tag[Exhibitions]!tag[Index]]"
/>


<$
log message="macrocall exhibition_id" value={{$:/TLS/artwork_id}} />



<$button actions=<<buttonActions>> >
Link Artworks to Exhibition
</$button>


In a rush but hope this helps. You were assigning the same value for artwork id over and over from a tiddler, instead of getting it from the field of the current tiddler in the list loop.

Bob Jansen

unread,
Oct 6, 2020, 7:49:43 PM10/6/20
to tiddl...@googlegroups.com
Saw,

Ah bugger, you are right. I have been looking at this for over a day and did not spot this. This is the problem with trying various ideas and stuff from one idea gets left behind.

Will change and hopefully this will fix things.

Bobj

Dr. Bob Jansen
122 Cameron St, Rockdale NSW 2216, Australia
Skype: bobjtls

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/ade9rEZzuPg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.

Bob Jansen

unread,
Oct 6, 2020, 7:52:14 PM10/6/20
to tiddl...@googlegroups.com
Saq 

Sorry for misspelling your name. I am currently on my iPhone and it thinks it is correcting me 

Bobj

Dr. Bob Jansen
122 Cameron St, Rockdale NSW 2216, Australia
Skype: bobjtls


On 7 Oct 2020, at 10:30, Saq Imtiaz <saq.i...@gmail.com> wrote:

Joshua Fontany

unread,
Oct 6, 2020, 8:03:53 PM10/6/20
to TiddlyWiki
Saq has a really good eye for wikitext. Thank man!

Syntax gremlins still get to me. Hope this is working out for you.

Best,
Joshua Fontany

TW Tones

unread,
Oct 7, 2020, 12:17:41 AM10/7/20
to TiddlyWiki
Bob,

Lest say you choose a name bobj

It would serve you well to put macros in a tiddler $:/bobj/project-name/macros and tag it macros

In this case the project-name may be gallary-ops

So it you were using a viewTemplate it would be called $:/bobj/gallary-ops/viewTemplate

This not only allows you to build the solution with a distinct set of hidden system tiddlers for code etc but allows you to list export them as [prefix[$:/bobj/gallary-ops]] and apply to another wiki.

You can then collect code into functional tiddlers and help those debugging look for macros etc.. in the correct place by tiddler title.

Additional filters in a single tiddler could also list all relevant tiddlers. Rather than tagging exhibitions artworks consignments etc.. set a field object-type to each of these values. You can then list them with a filter [object-type[artworks]] and save tags for ad hoc organisation.

Regards
Tony

On Monday, 5 October 2020 17:05:50 UTC+11, Bob Jansen wrote:

Bob Jansen

unread,
Oct 7, 2020, 12:28:44 AM10/7/20
to TiddlyWiki
Tones,
Sounds interesting as a way for me to provide an update mechanism for my TW users. I will study what you say and make changes accordingly.

bobj

Bob Jansen

unread,
Oct 7, 2020, 12:30:33 AM10/7/20
to TiddlyWiki
Tones, Saq and Joshua,

Thank you for all your help. My code now works as expected so I can move forward to the next 'obstacle' :-)

bobj

Bob Jansen

unread,
Oct 7, 2020, 1:50:40 AM10/7/20
to TiddlyWiki
Tones,

just seeking some clarification.

1. All macros are stored in the text field of the tiddler $:/bobj/gallery-ops/macros and this tiddler has the tag $:/tags/Macro or is each macro stored in a separate tiddler named $:/bobj/gallery-ops/name_of_macro with the tag $:/tags/Macro

2. I assume all view templates would be renamed to have the prefix  $:/bobj/gallery-ops/ and remain tagged with $:/tags/ViewTemplate

3. What do you mean by 'You can then collect code into functional tiddlers'

bobj

TW Tones

unread,
Oct 7, 2020, 3:06:56 AM10/7/20
to TiddlyWiki
Bob,

First such a set of naming standards can help immediately by helping you keep track, but its also easier to bundle, transfer and share, and people hepling you can workout the components by looking at the tiddler titles.

On Wednesday, 7 October 2020 16:50:40 UTC+11, Bob Jansen wrote:
just seeking some clarification.

sure 

1. All macros are stored in the text field of the tiddler $:/bobj/gallery-ops/macros and this tiddler has the tag $:/tags/Macro or is each macro stored in a separate tiddler named $:/bobj/gallery-ops/name_of_macro with the tag $:/tags/Macro
   and this tiddler has the tag $:/tags/Macro or is each macro stored in a separate tiddler named $:/bobj/gallery-ops/name_of_macro with the tag $:/tags/Macro

One tiddler "$:/bobj/gallery-ops/macros" is fine as long as they are each single line or terminated with \end 
Incidentally after the last definition you can see the standard content and you can use there to document your own macros. Apparently this additional content is not included when generating the macros.

But you choose how to organise them. one or many

There is now an alternate tag that is a little more specific https://tiddlywiki.com/prerelease/#SystemTag%3A%20%24%3A%2Ftags%2FMacro%2FView


2. I assume all view templates would be renamed to have the prefix  $:/bobj/gallery-ops/ and remain tagged with $:/tags/ViewTemplate

Yes, that makes sense because you only normally see view templates as they are displayed.

Using system tiddlers hides them by default from searches, they don't come up in recent.
 

3. What do you mean by 'You can then collect code into functional tiddlers'

  • Well the tiddler titles are within the project they belong to, without using tags and have meaningfull and somewhat invariant names.
  • [prefix[$:/bobj/gallery-ops]] will list them all
  • All macros will be found in the same tiddler for each project or at least have macros in the title
  • The tiddler viewTemplate perhaps even editTemplate will be clearly named as such and that is where you find their content
By using such a standard I now have a large library of projects and have written another project designed to work with the project tiddlers.

I have attached an unpublished solution which gives an example, add it to tiddlywiki.com It creates to buttons that allow you to open tiddlers in full view (includes view template not just content)  or edit mode in a window,

After importing rename $:/import to any name to keep the list of tiddler and explore to see examples of how I organise (this is by no means complete)
Edit $:/PSaT/new-windows and look at the fields which define each project.

Not in the attached package but in others for example I include $:/PSaT/project-name/helper containing a set of macros I use in multiple projects;

Rather than make them global I use; 
\import $:/PSaT/project-name/helper
See here https://tiddlywiki.com/#ImportVariablesWidget

Regards
Tones
new-windows.json
Reply all
Reply to author
Forward
0 new messages