Constructing a nested Filter

I’m struggling with this filter. So, here is a description of what I am trying to do.

I have a TW which is essentially a buildings database. There are tiddlers representing:

  • Architect
  • Premises (has a field named ‘Architect’ populated with Architect)
  • Images - as jpg files (has a field named ‘Building’ populated with Premises)

For each Architect there may of course be mutiple premises and for each Premises there may be multiple images. So both are one-to-many.

For each Architect I want to display (i.e. transclude) the relevant images.

Step 1. Find the Premises

[all[tiddlers]search:Architect<currentTiddler>]

Step 2. Find the Images

[[all[tiddlers]search:title:[jpg]]search:Building[all[tiddlers]search:Architect<currentTiddler>]]

Wrapping it all together in the parent Architect tiddler:

<$list filter="[[all[tiddlers]search:title:[jpg]]search:Building[all[tiddlers]search:Architect<currentTiddler>]]">
<$image source=<<currentTiddler>> width="200px"/>
</$list>

but, it does not work! Help, please.

[all[tiddlers]Architect<currentTiddler>] :map:flat[[is[image]Building<currentTiddler>]

This assumes that:

  • each Premise has a single Architect
  • each Image has a single Premise
  • that the images are saved in the wiki

The first run gets all the Premises for the Architect.
The second run gets all the images for each Premise.

1 Like

We seem to have a mismatch of the square brackets in the second phrase? Even tweaking that a few ways I only get a missing image placeholder.

Is my use of

<$image source=<<currentTiddler>> width="200px"/>

after the filter correct?

Let me try and expand the explanation:

  1. From the starting tidddler its title gives us the Architect’s name
  2. Search all Achitect fields and find Premises tiddler(s)
  3. This Premises tiddler has a field named Building
  4. The Building value is matched to Building field in the image tiddlers (jpg)

Just at a quick glance I see the syntax error, use one not two [

Thanks @TW_Tones

It sorts my syntax error, what I had written does produce an output but not what I had intended! Rather that just showing a subset of images it actually displays all the images in my wiki. So I guess that’s where @saqimtiaz addition of the :map:flat operator comes in, but once I introduce that I get a error:

<$list filter="[all[tiddlers]search:title:[jpg]] :map:flat[search:Building[all[tiddlers]search:Architect<currentTiddler>]]">
<$image source=<<currentTiddler>> width="200px"/>
</$list>

<img src="Filter error: Syntax error in filter expression" width="200px" class=" tc-image-error">

So, we’re getting there but I still need some help!

Try this with the syntax error corrected:

[all[tiddlers]Architect<currentTiddler>] :map:flat[is[image]Building<currentTiddler>]

If that still does not work, please share a wiki or some sample tiddlers to help debugging.

@saqimtiaz et al.

Hopefully to make it easier to debug I have set up a demo wiki https://myfta.github.io/

The filter I’m having trouble with is in the tiddler Frank Mosley. It currently reads:

<$list filter="[all[tiddlers]Architect<currentTiddler>] :map:flat[is[image]Property<currentTiddler>]">
<$image source=<<currentTiddler>> width="200px"/>
</$list>

Here is the logic.
The tiddler for image St Johns Road.jpg has a field Building with a value St Johns Road

The tiddler Central Community Centre has fields Architect with a value of [[Frank Mosley]], and a Property of St Johns Road

What I am trying to do is show the image in the architect tiddler Frank Mosley. Potentially, there could be several images from different buildings that need to be displayed in the architect tiddler.

Thanks.

[all[tiddlers]contains:Architect<currentTiddler>get[Property]] :map:flat[all[tiddlers]Building<currentTiddler>is[image]]

or if your use of the Property tag is consistent this will be faster:

[all[tiddlers]tag[Property]contains:Architect<currentTiddler>get[Property]] :map:flat[all[tiddlers]Building<currentTiddler>is[image]]

2 Likes

Of course it works and beautiful too! Thank you.