Help with templates, fields, and searchability

If you’ve truly given up, then ok.

If you’re looking for suggestions, there are people willing to help, but I think we’d need actual questions.

Fields are one way of doing things. I have some wikis where almost everything is handled with fields and templates, and there’s little text content. I have others where I touch almost no fields except for the big-Ts, title, tags, and text. It depends upon my need.

2 Likes

The issues I have are:

  1. You can’t enter newlines into the standard field entry form when creating a tiddler, making it hard to make field-heavy tiddlers out of the box.
  2. The search box only searches title and text values, not any of the other fields, making it hard to search for field-heavy tiddlers out of the box.
  3. The solutions to these problems require a lot of verbose markup.

The example of a tiddler entry form given above, while impressive, is beyond arcane to me. Yes I’ve tried looking up the documentation, but I get confused. It’s the same sort of befuddlement I feel when people try to use YAML as a programming language.

The other big reason I’m moving away from fields is that they’re not hierarchical. I mentioned above that i have to distinguish between polysemy and homophony. The word Dbr can mean both to meditate and to research. That’s polysemy, one word with shades of meaning. B is both the verb to attempt and the preposition from, that’s homophony, two separate words that sound the same. These are indicated differently. Homophony in particular would be hard with fields, as you now have one entry–one tiddler-- with multiple parts of speech, so I can’t just have “partOfSpeech” as a single field.

Don’t get me wrong, TW still succeeds at the stuff that attracted me to it in the first place. It has case sensitive links and it’s very easily sharable, but the learning curve is steep.

EDIT: Oops, I missed the fact that @Springer had already provided a demo of multi-line fields above! I’ll leave this for posterity since I did try to outline the mechanics a little further.

If you would like multi-line fields, this one has a pretty easy fix. Here’s a package you can drag and drop into your wiki to try it out; a basic explanation follows. multiline fields.json (701 Bytes)

The edit widget used for a given field name is controlled by a cascade, as shown below:

Here, #2 shows the default core tiddler that will be used to render each field in the editor. #1 is an alternative that takes precedence over the default (since it appears higher in the list). To make $:/my/ui/EditTemplate/fieldEditor/textarea, I cloned the default tiddler and very lightly tweaked it to use a textarea rather than a single-line input.

As written (and as presented in my sample file above), this will affect all fields in the editor. If I wanted to change only a subset of fields, I could use a filter like

[<currentField>match[long]then[$:/my/ui/EditTemplate/fieldEditor/textarea]]
~[<currentField>match[select]then[$:/my/ui/EditTemplate/fieldEditor/select]]

Then, assuming that I had created $:/my/ui/EditTemplate/fieldEditor/textarea and $:/my/ui/EditTemplate/fieldEditor/select tiddlers containing the appropriate widgets, the long field would be globally rendered with a textarea, the select field would be rendered with a dropdown (based on the one in that template tiddler), and all other fields would use the default input.

No you can’t not out of the box. But many have needed this, and there’s plenty of discussion on it, including several solutions: https://talk.tiddlywiki.org/search?q=multiline%20fields.

Again, this is a fairly common need, but not common enough to make it to the core: https://talk.tiddlywiki.org/search?q=searching%20in%20other%20fields.

That is one drawback of using a generic toolkit rather than a dedicated tool; you need to do the customization.

Many users would look at that and see relatively simple markup. It depends on how much time you want to invest in it. And it takes time, I’m afraid, to get good at it.

I really hope people are only using that as a markup language! If they’re trying to program logic with it, that would be really scary!

No, neither are SQL columns. Columns are a very good analogy to fields, and tiddlers to rows, with certain tags mapping to tables. I don’t know if you know SQL, but I imagine the spreadsheet concept of rows and columns is familiar. SQL tables are also not hierarchical. Nor are spreadsheets. And columns could never be, not directly. But people model hierarchical relationships in SQL all the time. And in spreadsheets. We can do that too in TiddlyWiki by making hierarchical groups of tiddlers. It pays to remember this:

From The Philosophy of Tiddlers:

The purpose of recording and organising information is so that it can be used again. The value of recorded information is directly proportional to the ease with which it can be re-used.

The philosophy of tiddlers is that we maximise the possibilities for re-use by slicing information up into the smallest semantically meaningful units with rich modelling of relationships between them. Then we use aggregation and composition to weave the fragments together to present narrative stories.

TiddlyWiki aspires to provide an algebra for tiddlers, a concise way of expressing and exploring the relationships between items of information.

If I were to try to model this, just on the little bit I know, I would probably have one tiddler for each Term and a number of separate tiddlers for each of its Definitions

title: down
tags: Term
pronunciation: / daʊn /
title: def/down/1
tags: Definition
term: down
part-of-speech: adverb
example: to come down the ladder.

from higher to lower; in descending direction or order; toward, into, or in a lower position

These definitions are a selection of the more than 50 definitions of “down” found on dictionary.com

definitions
title: def/down/1
tags: Definition
term: down
part-of-speech: adverb
example: to come down the ladder.

from higher to lower; in descending direction or order; toward, into, or in a lower position
title: def/down/2
tags: Definition
term: down
part-of-speech: adverb
example: He fell down.

on or to the ground, floor, or bottom:
title: def/down/20
tags: Definition
term: down
part-of-speech: preposition
example: They ran off down the street.

in a descending or more remote direction or place on, over, or along
title: def/down/22
tags: Definition
term: down
part-of-speech: adjective

being at a low position or on the ground, floor, or bottom.
title: def/down/36
tags: Definition
term: down
part-of-speech: noun

a downward movement; descent.
title: def/down/41
tags: Definition
term: down
part-of-speech: verb-transitive
example: He downed his opponent in the third round.

to put, knock, or throw down; subdue:
title: def/down/42
tags: Definition
term: down
part-of-speech: verb-transitive
example: to down a tankard of ale.

to drink down, especially quickly or in one gulp:
title: def/down/45
tags: Definition
term: down
part-of-speech: verb-intransitive

to go down; fall.
title: def/down/46
tags: Definition
term: down
part-of-speech: interjection
example: Down, Rover!

(used as a command to a dog to stop attacking, to stop jumping on someone, to get off a couch or chair, etc.):

def/down/1

I would apply a ViewTemplate to all Term tiddlers like this:

title: Term ViewTemplate
tags: $:/tags/ViewTemplate

<% if [<currentTiddler>tag[Term]] %>

!! Pronunciation

{{!!pronunciation}}

!! Definitions

<$let prefix={{{ [<currentTiddler>addprefix[def/]addsuffix[/]] }}}>
<table>
<tr><th>id</th><th>part of speech</th><th>definition</th></tr>
<$list filter="[tag[Definition]term<currentTiddler>]">
<tr>
<td><$link><$text text={{{ [<currentTiddler>removeprefix<prefix>] }}} /></$link></td>
<td><$link to={{!!part-of-speech}}>//{{!!part-of-speech}}//</$link></td>
<td>{{!!text}}</td>
</tr>
<% if [<currentTiddler>has[example]] %>
<tr><td colspan="2">&nbsp;</td><td class="example">{{!!example}}</td></tr>
<% endif %>
</$list>
</table>
</$let>

While that might look like gobbledygook to you, we can help you break this down into meaningful chunks should you want to learn this technique.

In the end, we could get a tiddler like this:

You can try this out by downloading the following and dragging the resulting file onto any TW; I’d suggest tiddlywiki.com:

Definitions.json (3.2 KB)

Open the down tiddler to see the results.


But again, this may not be for you. TiddlyWiki is not a system to display linguistic information. It is a general-purpose tool that may allow you to build such a system for yourself.

2 Likes

Some possibly helpful information

The standard search in the sidebar is designed to not overwhelm people so only searches the afformentioned fields rather than all fields.

To place things in the side bar we use the tag $:/tags/SideBarSegment so place this in a tiddler
<<tag $:/tags/SideBarSegment>> and click on the tag pill to see the items in the sidebar.

  • You will see $:/core/ui/SideBarSegments/search is the tiddler that delivers the standard search. Open thius tiddler

The standard search is quite complex code because of the need to respond with each character entered immediatly after the third is entered by default.

  • However to cut a long story short there is a tiddler $:/core/ui/DefaultSearchResultList and if you edit it you will see some fields containing filters.

first-search-filter the “title maches” filter [!is[system]search:title<userInput>sort[title]limit[250]]

  • This only searches title as this is the most importiant way to search, and most meaningful

second-search-filter the “All maches” filter
[!is[system]search<userInput>sort[title]limit[250]]

  • This does not specify any fieldnames so uses the default for the search operator which says the fieldlist defaults to tags, text and title if blank, see below;

So if you alter second-search-filter it will search all fields (however only if !is[system] ie not if a system tiddler begining $:/)

I suggest to alter the filter to;
[!is[system]search:*<userInput>sort[title]limit[250]]
which will search all non system tiddlers fields.

Keep in mind you can use similar filters in the advanced search filters tab.

Documentation

The search operator uses an extended syntax that permits multiple fields and flags to be passed:

[search:<field list>:<flag list>[<parameter>]]
  • field list: a comma delimited list of field names to restrict the search
    • defaults to tags, text and title if blank
    • an asterisk * instead of the field list causes the search to be performed across all fields available on each tiddler
    • preceding the list with a minus sign - reverses the order so that the search is performed on all fields except the listed fields
  • flag list: a comma delimited list of flags (defaults to words if blank)
  • parameter: filter parameter

These are used to generate the search dropdown

I did create the field-search plugin. Which allows you to define which fields you want to search in.

I did create the field-editor plugin, which allows you to switch between fields you want to edit in multi-line mode. It will also install the field-view plugin

More details can also be found at: [Intro] Multiline Field Editor Plugin