How to do a second, third, etc tags field in edittemplate?

12 views
Skip to first unread message

Dave Gifford - http://www.giffmex.org/

unread,
May 11, 2009, 10:19:36 PM5/11/09
to TiddlyWiki
Hi guys

I know it's been a long time. Got a question for you all:

Is there a way in edittemplate to create a custom edit tag field so
that I can assign a tiddler a tag within a special category of tags?
Kind of like a shortcut instead of doing formtemplate and
datatemplate?

Here's the setup: I'm doing a database of hymns. The list of tags will
be normal. But a certain hymn might be found in different hymnals with
different #s. So I'd like to create a special edit tags field for each
hymnal, then type in the hymn number in that hymnbook's field in edit
mode, then have a foreachtiddler code pull that number and put it into
a table.

Is this doable, or do I need to use datatemplate and formtemplate for
this?

Dave Gifford

Eric Shulman

unread,
May 11, 2009, 10:46:55 PM5/11/09
to TiddlyWiki
> Is there a way in edittemplate to create a custom edit tag field so
> that I can assign a tiddler a tag within a special category of tags?
> Kind of like a shortcut instead of doing formtemplate and
> datatemplate?
> Here's the setup: I'm doing a database of hymns. The list of tags will
> be normal. But a certain hymn might be found in different hymnals with
> different #s. So I'd like to create a special edit tags field for each
> hymnal, then type in the hymn number in that hymnbook's field in edit
> mode, then have a foreachtiddler code pull that number and put it into
> a table.

Add custom tiddler fields is very easy... First, add something like
this to your EditTemplate:

<div class='editor' macro='edit othertags'></div>

Then, to access the stored value in a <<forEachTiddler>> macro, you
can write something like:

tiddler.fields['othertags']

Note: the fieldname (e.g., 'othertags') must be all lower case.

enjoy,
-e

Dave Gifford

unread,
May 11, 2009, 11:33:41 PM5/11/09
to TiddlyWiki
Thanks for the quick reply, Eric!

The edittemplate fix is awesome. Very helpful.

But the FET code doesn't work. Rather than use othertags, I used sdg.

When I do:

<<forEachTiddler where 'tiddler.tags.contains("SDG")'
write '"|[["+tiddler.title+"]]|SDG:"+tiddler.fields['sdg']+"|"'
>>

I get

<<forEachTiddler ...>>: Extra parameter behind 'write': sdg']+"|"'

It tells me that tidder.fields is not a

When I do:

<<forEachTiddler where 'tiddler.tags.contains("SDG")'
write '"|[["+tiddler.title+"]]|SDG:"+tiddler.sdg+"|"'
>>

It looks better but what should show the tag from sdg comes up as
undefined.

Dave

Dave Gifford

unread,
May 11, 2009, 11:38:27 PM5/11/09
to TiddlyWiki
write '"|[["+tiddler.title+"]]|SDG:"+tiddler.fields("sdg")+"|"'>>

Gives me

<<forEachTiddler ...>>: TypeError: tiddler.fields is not a function

Dave

Eric Shulman

unread,
May 11, 2009, 11:45:35 PM5/11/09
to TiddlyWiki
> <<forEachTiddler where 'tiddler.tags.contains("SDG")'
> write '"|[["+tiddler.title+"]]|SDG:"+tiddler.fields['sdg']+"|"'

You have to be careful about mixing up your single and double quotes.
There are single-quotes around the write '...' clause. Thus, you
can't use single-quotes *within* that clause...

Thus, write:
write '"|[["+tiddler.title+"]]|SDG:"+tiddler.fields["sdg"]+"|"'

note: tiddler.fields is an *object*, not a function. Thus,
tiddler.fields["foo"] is a reference to the "foo" property of the
tiddler.fields object.

enjoy,
-e

Dave Gifford

unread,
May 11, 2009, 11:48:23 PM5/11/09
to TiddlyWiki
Thanks that did the trick. I could have sworn that I tried that option
too, among my experiments, but I guess not.

Blessings

Dave
Reply all
Reply to author
Forward
0 new messages