Regular Expression with currentTiddler title

Hello,

I think it’s sometimes helpful to have a kind of hirarchy in TiddlyWiki. I have therefore created the titles with colon separated topics, so for example I have some tiddlers for TiddlyWiki plugins:

TiddlyWiki:Plugin:relink
TiddlyWiki:Plugin:Shiraz
TiddlyWiki:Plugin:Projectify

What I want is a link at the buttom of the above tiddlers to TiddlyWiki:Plugin. And then a link at the buttom of the tiddler TiddlyWiki:Plugin to TiddlyWiki.

I know this is possible with a ViewTemplate, but I struggle to get the right filter expression inside the list-links macro. I think I need to pass the currentTiddler title to a regular expression, which will remove everything after the last colon (including the last colon).

I started with something like this:

<<list-search filter:"[all[current]regexp[/.+(?=\:)/]]">>

But I’m not sure if my regular expression is wrong or if this approach is in general wrong and I have to write a macro etc.

Can someone help?

Give this a try:

<$link to={{{ [<currentTiddler>split[:]butlast[]join[:]] }}}/>

enjoy,
-e

3 Likes

Works perfectly, thank you :slightly_smiling_face:

@Taltessy I am glad Eric helped you solve this issue, but I would just like to take the devil’s advocate position and warn against “compound titles”.

  • Experience and coding knowledge suggests this is unwise in the long run especially as titles are “unique keys” and what drives tiddlywiki.
  • There are host of other ways to capture relationships between tiddlers such as hierarchies’ which will also be easier to implement and have more possibilities. We can help you here to find these better ways.

Sure in simple cases this may work but it has a set of consequences if you want to move content between wikis, your wiki developes further, you want to leverage others existing tools and many more.

All I am saying is going forward, in future designs it is a good rule of thumb to;

Avoid the use of compound titles

@TW_Tones: I appreciate your recommendation against compound titles, but I have to admit that I do use them, too. Also, the $:/core is one big heap of compound titles and there exist filters (e.g. splitbefore) just to deal with them and create nice tables of content from that structure.
I do not use them for structuring – that’s what tag hierarchies are for – but just to make my titles as concise as possible (I use the caption field a lot to be more verbose).
On the other hand, I would be very frustrated with my compound titles were it not for Flibbles’ Relink Plugin. Because you are right, when structures change a tag is easily swapped, but until Relink a title was near forever, like a diamond. That’s why @Flibbles is my No.2 TW-Hero, after @jeremyruston of course.

So as an extensive user of compound titles I fully agree with your warning about compound titles. :wink:

Have a compounded day
Yaisog

3 Likes

Thanks for your recommendation. I really welcome any tips to avoid future problems. I would like to describe how I use the titles in more detail, but this was already perfectly done by @Yaisog :smile: :

I only use compound titles when it’s nearly impossible that the title will change in the future. Let’s take the example from above with TiddlyWiki:Plugin:Shiraz. There is nearly no chance that

  1. Shiraz will be renamed (could be easily fixed with relink plugin)
  2. Shiraz will be a general plugin for various software and therefore will not be a TiddlyWiki plugin only
  3. TiddlyWiki will be renamed

So the compound title just gives me a concise title with the benefit that it’s a unique title. When I only use Shiraz as the title it could be about the city Shiraz or about the TiddlyWiki plugin. To solve this I could use a title like Shiraz the TiddlyWiki Plugin. Or I just use TiddlyWiki:Plugin:Shiraz. It’s also easy to identify from the title what could be inside the tiddler text.

Does this make sense or could this be solved better?

2 Likes

Does this mean you know @Mohammad personally?

2 Likes

No, why do you you mean?

Yes. In the core we call this mechanism “namespace”. Core names are discussed in the docs at: Naming of System Tiddlers.

There is also the tree-macro, which allows you to show those structures in a “directory tree” like view.

You can see it “in action” in the Right sidebar : More : Explorer tab.

@Mohammad lives there to my knowledge. We Australians love Shiraz wines made from the Shiraz grape presumably developed there.

1 Like

I remembered that Mohammad named his plugins after cities so I thought this is a perfect example of two things (city and TiddlyWiki plugin) which could have the same title but completely different meaning :smile:

1 Like

What twins would you go for :smiley:?

One calls it compound titles, the other namespace. :grin:
Either way, I use my own namespace for naming content tiddlers, and tags for creating the hierarchy. Both not always match, but Relink helps.

Within the $:/core namespace (or my personal $:/ subspace), I spend waaaay too much time wondering how to structure tiddlers. If I have a separate StyleSheet for the SideBar, does it go under /ui/SideBar or under /ui/StyleSheets? :thinking: :confounded: :woozy_face:
Only one thing is guaranteed: When I’m looking for them I’ll look in the wrong place first…
Have a decisive day
Yaisog

Absolutely true. – Naming tiddlers is hard. Especially, since we don’t see a pattern immediately. We have to have many tiddlers, that “do” similar things to see, how they should be categorized and may be re-named properly. … I think it needs several iterations, to find a workable and “stable” structure. Maybe “trial and error” is part of the game here :wink:

Until we have something like a TiddlyWiki5 Ontology, that’s the way to go…

It is clear we need to distinguish between the terms compound title (or key) and a title which uses a namespace, or as I illustrate a “unique or display title”. To reuse a well known phrase;

The tiddler title should be the title, the whole title and nothing but the title.

While naming tiddlers we can apply a naming standard such as the “structured subtiddlers” $:/top/middle/bottom to in effect add more information into the title, this is in effect a naming standard which arguably give rise to two “namespaces” that of $:/top/ and $:/top/middle/ it is not a compound title such as blog entry 2022/13/04 tiddlywiki which contains the type of tiddler “a blog” the “date” it refers to and the subject area “tiddlywiki”.

Now let me neuence my previous rule to avoid compound tiddler titles.

Now to be honest this example title blog entry 2022/13/04 tiddlywiki is not a problem, if it is intended to be a “display title” if contained within the tiddler we separately record the type/date and subject, be it with fields or tags. That is a “display title” may make a “unique title” for the tiddler, but we do not need to parse it because that is the only place we store the “type/date and subject”, as we have it elsewhere in the tiddler.

So here I refine my previous statement;

Avoid the use of compound titles as the only place to record more than one “key value”.

The truth is on the surface it is a “fine” distinction but, “on my word it is an important one”.

In other words

Except for the purpose of generating a unique key, avoid using the tiddler title as the only place to store more than one “key” piece of information, relating to what is contained within the tiddler. Otherwise when you want to search using one of these keys, you will need to “parse titles” just to find the key, before you even filter or search based on the key.

2 Likes