search widget odd behaviour

62 views
Skip to first unread message

Bob Jansen

unread,
Sep 17, 2020, 2:37:09 AM9/17/20
to TiddlyWiki
I have three tiddlers, tag=Names, TK5, TK6 and TK7. Each has a field, artwork_id but only TK5 has artwork_id=TK1. the other two have an empty field.

I have a tiddler, TK1 which has a field artwork_id with value TK1.

TK1 calls a macro  <<is_purchased_by {{!!artwork_id}} >>

The macro is:
\define is_purchased_by(artworkID)
<$wikify name="artID" text=[$artworkID$] >
<$log $message="hello world" myvalue=artID />
<$list filter="[[$artworkID$]!is[blank]]" variable="not_blank">
   <$list filter="[tag[Names]!tag[Index]!match<currentTiddler>search:artwork_id[$(artID)$]]">
      &bull; <$link to={{!!name_id}}><$view field="title"/> <$view field="person_name"/></$link><br/>
   </$list>
</$list>
</$wikify>
\end

The result is a bulleted list 
• TK5 name-tk5
• TK6 name-tk6
• TK7 name-tk7

I would have expected only the first since that is the tiddler with TK1 in the artwork_id field. The parameter is wikify'd to [TK1]

So, the search widget is not behaving as expected.

Any clues?

bobj

Saq Imtiaz

unread,
Sep 17, 2020, 4:19:42 AM9/17/20
to TiddlyWiki
Hi Bob,

A few things to consider here.

Firstly, when you want to pass an indirect parameter (via text reference) to a macro, you cannot use the form:
<<is_purchased_by {{!!artwork_id}} >>

Instead, you need to use the macrocall widget:
<$macrocall $name="is_purchased_by" artWorkID={{!!artwork_id}} />


Also, I think you will have an easier time of it if you have a field "buyer" in all the artwork tiddlers which contains an ID for the buyer, and the tiddlers describing buyers have their ID stored in a field "person_id". 

Then in a Person tiddler to see all the artwork they have bought:
<$list filter="[buyer{!!person_id}]">
<$view field="artwork_title"/>
</$list>

And in an artwork tiddler to see the buyer's name:
<$text text={{{ [ person_id{!!buyer}get[person_name] }}} />

This should be easier than dealing with a field in artwork_id field in buyers that is supposed to contain multiple values (which I assume is the current structure).

Lastly, it might be worth considering to have different name prefixes for tiddlers describing People and Art, e.g. Person P1 and Artwork TK1. The idea being to be able to distinguish at a glance from the title if we are looking at a tiddler describing a person or an artwork.

Hope this helps,
Saq

Dr Bob Jansen

unread,
Sep 17, 2020, 5:27:07 AM9/17/20
to tiddl...@googlegroups.com
Saq,

Thank you for your email and comments.

The issue of one-to-many links is replicated in other relationships and so the issue still need to be resolved. Also, in the case of a print, there is more than one buyer of an artwork and thus we need the search facility.

The issue of the macrocall has been addressed through the wikify statement but now that I have the basics of the macro working may revert back to using a macrocall instead of the <<..>> syntax.

As for different unique ID codes, I have considered this and may convert. However it will not make much difference to the user as the detailed display of any tiddler will make it immediately obvious what type of content is being displayed, artwork, person, consignment, exhibition, etc.

Bobj

---------------
Dr Bob Jansen
The Cultural Conversations project 
Turtle Lane Studios Pty Ltd trading as the Australian Centre for Oral History
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://www.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"
--
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/cOSbp3Km6KU/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/32647120-52ab-40f9-b001-5c50bc97e9d5o%40googlegroups.com.

Eric Shulman

unread,
Sep 17, 2020, 5:37:03 AM9/17/20
to TiddlyWiki
On Wednesday, September 16, 2020 at 11:37:09 PM UTC-7, Bob Jansen wrote:
I have three tiddlers, tag=Names, TK5, TK6 and TK7. Each has a field, artwork_id but only TK5 has artwork_id=TK1. the other two have an empty field.
I have a tiddler, TK1 which has a field artwork_id with value TK1.
TK1 calls a macro  <<is_purchased_by {{!!artwork_id}} >>

The macro is:
\define is_purchased_by(artworkID)
<$wikify name="artID" text=[$artworkID$] >
<$log $message="hello world" myvalue=artID />
<$list filter="[[$artworkID$]!is[blank]]" variable="not_blank">
   
<$list filter="[tag[Names]!tag[Index]!match<currentTiddler>search:artwork_id[$(artID)$]]">
     
&bull; <$link to={{!!name_id}}><$view field="title"/> <$view field="person_name"/></$link><br/>
   
</$list>
</
$list>
</$wikify>
\end

1) You shouldn't need to wikify the $artworkID$
2) In your second list filter, you reference $(artID)$ ... but that is incorrect, since the $(...)$ form of reference is only for variables that are defined *outside* of the current macro.
3) Try re-writing your filter like this:
   <$list filter="[tag[Names]!tag[Index]!match<currentTiddler>search:artwork_id[$artworkID$]]">
-e

Dr. Bob Jansen

unread,
Sep 17, 2020, 6:51:34 AM9/17/20
to tiddl...@googlegroups.com
Eric,

that doesn't work, no results returned.

Have also tried

<$list filter="[tag[Names]!tag[Index]!match<currentTiddler>search:artwork_id[$artID$]]">

which doesn't work either, no results returned.

Interestingly, Saq's comment about replacing the call to the macro with

<$macrocall $name="is_purchased_by" artWorkID={{!!artwork_id}} />

also leads to no results returned.

The only combination of macro calling and macro code that returns any result, albeit the wrong one, is what I have provided.

Is there any other way to scan a field looking for a specific text string?

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/cOSbp3Km6KU/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/17b4f445-4523-4cd4-b2ee-de2fefdd595fo%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

Dr. Bob Jansen

unread,
Sep 17, 2020, 7:03:33 AM9/17/20
to tiddl...@googlegroups.com
Colleagues,

just some more experimenting.

If I put something into the artwork_id field of TK6 and TK7, for example, "TK2", the result displayed remains TK5, TK6 and TK7. That implies the problem is that search is not correctly matching the field content with the search string.


bobj

On 17/9/20 7:37 pm, Eric Shulman wrote:
On Wednesday, September 16, 2020 at 11:37:09 PM UTC-7, Bob Jansen wrote:
I have three tiddlers, tag=Names, TK5, TK6 and TK7. Each has a field, artwork_id but only TK5 has artwork_id=TK1. the other two have an empty field.
I have a tiddler, TK1 which has a field artwork_id with value TK1.
TK1 calls a macro  <<is_purchased_by {{!!artwork_id}} >>

The macro is:
\define is_purchased_by(artworkID)
<$wikify name="artID" text=[$artworkID$] >
<$log $message="hello world" myvalue=artID />
<$list filter="[[$artworkID$]!is[blank]]" variable="not_blank">
   
<$list filter="[tag[Names]!tag[Index]!match<currentTiddler>search:artwork_id[$(artID)$]]">
     
&bull; <$link to={{!!name_id}}><$view field="title"/> <$view field="person_name"/></$link><br/>
   
</$list>
</
$list>
</$wikify>
\end



Dr. Bob Jansen

unread,
Sep 17, 2020, 8:02:36 AM9/17/20
to tiddl...@googlegroups.com
Colleagues,

Experimenting with the contains operator but having trouble with how to write the operator string correctly.

Am changing my <$list> structure to


<$list filter="[[$artworkID$]!is[blank]]" variable="not_blank">
   <$list filter="[tag[Names]!tag[Index]!match<currentTiddler>">
      <$list filter="[contains:artwork_id[$artID$]]">&bull; <$link to={{!!name_id}}><$view field="title"/> <$view field="person_name"/></$link><br/>
      </$list>
  </$list>
</$list>

Have tried other formats around the artID parameter but nothing returns any results.

What should the correct contains operator expression in this case be?


bobj

On 17/9/20 7:37 pm, Eric Shulman wrote:
On Wednesday, September 16, 2020 at 11:37:09 PM UTC-7, Bob Jansen wrote:
I have three tiddlers, tag=Names, TK5, TK6 and TK7. Each has a field, artwork_id but only TK5 has artwork_id=TK1. the other two have an empty field.
I have a tiddler, TK1 which has a field artwork_id with value TK1.
TK1 calls a macro  <<is_purchased_by {{!!artwork_id}} >>

The macro is:
\define is_purchased_by(artworkID)
<$wikify name="artID" text=[$artworkID$] >
<$log $message="hello world" myvalue=artID />
<$list filter="[[$artworkID$]!is[blank]]" variable="not_blank">
   
<$list filter="[tag[Names]!tag[Index]!match<currentTiddler>search:artwork_id[$(artID)$]]">
     
&bull; <$link to={{!!name_id}}><$view field="title"/> <$view field="person_name"/></$link><br/>
   
</$list>
</
$list>
</$wikify>
\end



Saq Imtiaz

unread,
Sep 17, 2020, 8:12:52 AM9/17/20
to TiddlyWiki
Try:
<$list filter="[[$artworkID$]!is[blank]]" variable="not_blank">
   <$list filter="[tag[Names]!tag[Index]!match<currentTiddler>contains:artwork_id[$artID$]]">
      <$view field="person_name"/><br/>
  </$list>
</$list>

If you still have issues, it would be a lot easier to assist if you could post a copy of your file where we can test things.

Dr. Bob Jansen

unread,
Sep 17, 2020, 8:34:30 AM9/17/20
to tiddl...@googlegroups.com
Sorry Saq, doesn't work either.

You can download a copy of the TW from http://cultconv.com/TLSConsignment.html

bobj


On 17/9/20 10:12 pm, Saq Imtiaz wrote:
Try:
<$list filter="[[$artworkID$]!is[blank]]" variable="not_blank">
   <$list filter="[tag[Names]!tag[Index]!match<currentTiddler>contains:artwork_id[$artID$]]">
      <$view field="person_name"/><br/>
  </$list>
</$list>

If you still have issues, it would be a lot easier to assist if you could post a copy of your file where we can test things.


Saq Imtiaz

unread,
Sep 17, 2020, 8:47:34 AM9/17/20
to TiddlyWiki
Bob,

Try entering this directly in the TK1 tiddler:

<$list filter="[{!!artwork_id}!is[blank]]" variable="not_blank">
   <$list filter="[tag[Names]!tag[Index]!match<currentTiddler>contains:artwork_id{!!artwork_id}]">
      <$view field="person_name"/><br/>
  </$list>
</$list>

Dr. Bob Jansen

unread,
Sep 17, 2020, 8:53:43 AM9/17/20
to tiddl...@googlegroups.com
Colleagues,

I should have added, if you are going to play with the file, the artwork that shows the wrong behaviour is TK1 and no other. The others don't have the correct macrocall in them.

The list appears under the text, "This artwork has been purchased by"

It should only show TK5.


bobj

On 17/9/20 10:12 pm, Saq Imtiaz wrote:
Try:
<$list filter="[[$artworkID$]!is[blank]]" variable="not_blank">
   <$list filter="[tag[Names]!tag[Index]!match<currentTiddler>contains:artwork_id[$artID$]]">
      <$view field="person_name"/><br/>
  </$list>
</$list>

If you still have issues, it would be a lot easier to assist if you could post a copy of your file where we can test things.


Saq Imtiaz

unread,
Sep 17, 2020, 8:56:29 AM9/17/20
to TiddlyWiki
You can further simplify things a lot by using custom view templates, so you don't need to manually call each macro etc in each artwork tiddler and each person tiddler.

For example, to get the same code applied to what you see for each Artworks tiddler,  create a tiddler with this content and give it the tag $:/tags/ViewTemplate:

<$list filter="[all[current]tag[Artworks]]" variable=null>

<img src={{!!artwork_url}}>


{{!!artwork_title}}, {{!!artwork_medium}}, {{!!artwork_size}}, {{!!artwork_yearofcreation}}


''This artwork has been exhibited in the following exhibitions''


<$macrocall name="is_exhibited_by" artwork_id={{!!artwork_id}} />


''This artwork has been consigned in the following consignments''


<$macrocall name="consigned_to" artwork_id={{!!artwork_id}} />


''This artwork has been purchased by''


<
<is_purchased_by {{!!artwork_id}} >>

</$list>

The very first list widget in that code determines which tiddlers have that template applied to them.

Dr Bob Jansen

unread,
Sep 17, 2020, 9:02:25 AM9/17/20
to tiddl...@googlegroups.com
Saq,

Ah, clever. Did not know about these templates.

Will try tomorrow.

Thanks for your help.

BobJ


---------------
Dr Bob Jansen
The Cultural Conversations project 
Turtle Lane Studios Pty Ltd trading as the Australian Centre for Oral History
Ph (Korea): +82 10-4494-0328 
Ph (Australia) +61 414 297 448 
Resume: http://au.linkedin.com/in/bobjan 
Skype: bobjtls 
KakaoTalk: bobjtls 

 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"
--
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/cOSbp3Km6KU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.

TW Tones

unread,
Sep 17, 2020, 8:27:48 PM9/17/20
to TiddlyWiki
Bob,

Perhaps this helps, or not, I have not read this topic.

fieldname[value] works in any filter to return only tiddlers with a fieldname with the ""value", it allows you to create things which look like new filter operators;
eg
display-code[show] 

However if you start using multiple titles/values within a field the list operators, the enlist, listops and search become your friends.

Alternatively on the current tiddler use a list to extract each value from a field and each independantly.

Regards
Tones
To unsubscribe from this group and all its topics, send an email to tiddl...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages