[TW5] Get certain characters of a tiddler title

147 views
Skip to first unread message

The Bo

unread,
Aug 9, 2016, 5:45:13 AM8/9/16
to TiddlyWiki
Hi,

I would like to display the first characters of a tiddler title.

For example
tiddler title: New Tiddler
number of characters: 3

This should display "New".

There must be a simple way I wasn't able to find until now. ;-)

Regards
The Bo




PMario

unread,
Aug 9, 2016, 8:33:19 AM8/9/16
to TiddlyWiki
Hi Bo,

I don't know an easy solution out of the box. ... If you describe, what you want to achieve, imo it may be possible to find an easy (and existing) way.

-mario

The Bo

unread,
Aug 9, 2016, 9:43:51 AM8/9/16
to TiddlyWiki
Hey Mario,

thanks for your support!
Ok... every tiddler in my TW-project is starting with the american date format yyyymmdd for better sorting.
Now I would like to seperate yyyy, mm and dd to build a german date format like dd.mm.yyyy and put it in a dynamic table via $list.

Regards,
The Bo

Mark S.

unread,
Aug 9, 2016, 12:33:40 PM8/9/16
to TiddlyWiki
If you don't mind having to create a filter with parts in it for every month/year, then this might work (I've done just 2 months here, 07 and 08):

<$list filter="[removeprefix[201608]addsuffix[.08.2016]] [removeprefix[201607]addsuffix[.07.2016]] +[sort[]]"><$view field="title"/><br/></$list>

If I might suggest, there might be a better way. How are you making the tiddlers now? Whatever mechanism, perhaps it could simultaneously date stamp the caption field (or some other field) with the german date format. Then your filter could be very simple, just selecting which field you wanted to sort on.

Good luck!
Mark

PMario

unread,
Aug 9, 2016, 1:17:21 PM8/9/16
to TiddlyWiki
Hi Bo,

If your tiddlers have the right created fields, you may use that to create your filters and lists.

testTiddler:

<ul>
<$list filter="[!is[system]regexp:created[^201408]]">
 <li>
  <$link to=<<currentTiddler>>>{{!!title}}</$link> --- <$view tiddler=<<currentTiddler>> field=created format="date" template="DDD DDth MMM YYYY"/>
  </li>
</$list>
</ul>


see: http://tiddlywiki.com/#ViewWidget:ViewWidget%20%5B%5Bregexp%20Operator%20(Examples)%5D%5D%20%5B%5Bregexp%20Operator%5D%5D%20%5B%5BDate%20Fields%5D%5D

have fun!
mario

PMario

unread,
Aug 9, 2016, 1:20:14 PM8/9/16
to tiddl...@googlegroups.com
This thread may also contain some useful info about filters: https://groups.google.com/forum/#!topic/tiddlywiki/MV_PqI97jPU
-m

The Bo

unread,
Aug 10, 2016, 3:42:30 AM8/10/16
to TiddlyWiki
Thank you both!

The problem is that the created stamp and the tiddler name date are different.

@Mark
The tiddler name date is starting in the year 1989 so it would be hard to create a filter for every year/month.

The Bo

unread,
Aug 10, 2016, 4:18:08 AM8/10/16
to tiddl...@googlegroups.com
I build a little macro which seems to fullfill what I'm looking for:

/*\
title: $:/macros/date_title.js
type: application/javascript
module-type: macro

Macro to get the date from a tiddler title if title is starting with an american date format (yyyymmdd) and convert it to date format dd.mm.yyyy.
\*/

(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

/*
Information about this macro
*/


exports
.name = "date_title";

exports
.params = [];

/*
Run the macro
*/

exports
.run = function() {
   
return this.getVariable("currentTiddler").substring(6,8) + "." + this.getVariable("currentTiddler").substring(4,6) + "." + this.getVariable("currentTiddler").substring(0,4);
};

})();


Reply all
Reply to author
Forward
0 new messages