Having individual "subject" fields will require a fair amount of wikitext
programming.
You might consider using the list field to list your subjects. It depends
on the overall nature and comprehensiveness of your task.
If you have a photo, say "Photo-1" and then use the "new here" button
available from the tiddler's drop-down, then you can create "subjects" who
are tagged with "Photo-1". You can then click on the tag "Photo-1" in any
of the subjects, and rearrange the subjects. For instance, you might want
to arrange the subjects in left-to-right order as they appear in the photo.
Then the list of the tagged tiddlers will appear in the "list" field of
"Photo-1". This has certain advantages. For one, the "list" field is one of
the few fields that TW will maintain for you. So, for instance, if you have
to change the title a bit ("Darn, it was Donald Trump *JR*."), then the
reference in the list can be (if you let it) be updated when you change the
title.
As you say, using "subject" fields will require you to do extra tricky
steps. You could use the regexp operator (there is one), but also the
"prefix" operator would probably work. But it will require at least one or
more extra nested loops to do it this way.
Merry Ho Ho and a bottle of Reindeer
On Thursday, December 12, 2019 at 11:00:31 AM UTC-8, Paul Lee wrote:
>
> I wish I could put a regex in a filter, in order to select all fields
> whose identifiers begin with the same group of characters in tiddlers
> inheriting one of my templates.
>
> The needed functionality is to loop through different fields with the same
> name except for a number at the end, outputting a phrase before the value
> of those fields only if that particular tiddler is present in the child
> tiddlers that will transclude the template. The intended purpose is to list
> people who are the subjects of photographs; each photograph tiddler has one
> or more "subject#" fields containing names. A portrait of John Smith has a
> field *subject 1: John Smith*, while an expedition photo of Lewis and
> Clark might have *subject1: Meriwether Lewis* and *subject2: William
> Clark*.
>
> Three thoughts about how to do this:
>
> - A regex in a $list widget, if such a thing were possible: <$list
> filter="[all[current]has[subject*[1-9]*]">
> - A *for* loop... I'm guessing this would require a macro? Would I
> define the index variable using the *$set* widget?
> - The *$fields* widget allows me to approximate what I want to do due
> to its useful *template* attribute, but it is difficult to foresee all
> the many fields that need to be exlcuded using its *exclude* attribute.
>
> I saw that there is an escaperegexp operator
> <https://tiddlywiki.com/#escaperegexp%20Operator>, but I'm guessing that
> this filter notation merely escapes regex strings?
>
> I don't really understand; I'm not a developer myself, merely a user who
> has learned basic JavaScript syntax.
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/4623c209-28e2-4d1e-b32f-1217581cd804%40googlegroups.com.