Discussion:
[tw] Custom list type fields - can these be saved and loaded?
(too old to reply)
emkay
2017-05-16 09:48:58 UTC
Permalink
Raw Message
Hello,

In my tiddlerdeserializer module I am creating a list field (not the
standard list nor tag fields). Let's call the field: 'parts'

When an import occurs my module runs and the field 'parts' is created as a
javascript list. This can then be read (as a list) in my javascript macro.

However when I save and reload the TW, the 'parts' field is now a normal
non-list field, i.e. a single string of characters.

Should this work, or am I straying out of supported behaviour?

Thanks

Martin
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/3f6d4191-fa46-4f9b-aab6-a7c5c5e2bd70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jed Carty
2017-05-16 10:57:22 UTC
Permalink
Raw Message
It sounds like what you want to do is possible but it may not be simple. It
is certainly not behaviour that is supported out of the box, but there is
very little in tiddlywiki that could be called 'unsupported behaviour'
because of how flexible it is.

I strongly suggest using the fields as normal text and then having whatever
is using the information parse the field text appropriately. I have been
trying to move tiddlywiki away from dedicated single purpose fields (like
how the tags field always has special handling) to using a polymorphic
field model.
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/eed0481f-efc5-4795-9d36-7c6aacab2ea4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Andreas Hahn' via TiddlyWiki
2017-05-16 16:36:34 UTC
Permalink
Raw Message
Hi Martin,

apart from whether its a good idea or not, it is indeed possible, but
the documentation on how to do it is very scarce. Basically though, I
think you would need to write a javascript module with `module-type:
tiddlerfield` that does something (probably very) similiar to what
boot.js does:

$tw.modules.define("$:/boot/tiddlerfields/tags","tiddlerfield",{
name: "tags",
parse: $tw.utils.parseStringArray,
stringify: $tw.utils.stringifyList
});

I am not 100% sure, but it seems to be what makes TW treat certain
fields differently from others. I've linked a few source code spots down
below, maybe those help you in getting this to work.

/Andreas

[1] https://github.com/Jermolene/TiddlyWiki5/blob/master/boot/boot.js#L866
[2]
https://github.com/Jermolene/TiddlyWiki5/blob/master/core/modules/tiddler.js#L27
[3] https://github.com/Jermolene/TiddlyWiki5/blob/master/boot/boot.js#L828

P.S.: Note that in the sample code from boot.js the module seems to be
defined in-place .. in a real module you would define the options via
exports.name or exports.parse etc.
Post by Jed Carty
It sounds like what you want to do is possible but it may not be
simple. It is certainly not behaviour that is supported out of the
box, but there is very little in tiddlywiki that could be called
'unsupported behaviour' because of how flexible it is.
I strongly suggest using the fields as normal text and then having
whatever is using the information parse the field text appropriately.
I have been trying to move tiddlywiki away from dedicated single
purpose fields (like how the tags field always has special handling)
to using a polymorphic field model.
--
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
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/eed0481f-efc5-4795-9d36-7c6aacab2ea4%40googlegroups.com
<https://groups.google.com/d/msgid/tiddlywiki/eed0481f-efc5-4795-9d36-7c6aacab2ea4%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/38a554b1-5add-86f8-b991-31260ee6be2f%40googlemail.com.
For more options, visit https://groups.google.com/d/optout.
emkay
2017-05-16 20:49:54 UTC
Permalink
Raw Message
Thank you, Andreas. That sounds fantastic. TW5 impresses again!

It will definitely be worth the effort of writing the module, to save me 'handamatically' serialising and deserialising all over my code.

Thanks again,

Martin
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/10435129-1d89-4102-8d25-65e5359ebfc4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...