Checkbox to turn on and off custom fields

79 views
Skip to first unread message

david.j....@gmail.com

unread,
Aug 3, 2007, 9:57:23 AM8/3/07
to TiddlyWiki
I was wondering what the best method would be to add checkboxes to
turn on and off custom fields.

Should I use TogglyTagging and then use those tags with the
HideWhenPlugin?

Eric Shulman

unread,
Aug 3, 2007, 11:06:26 AM8/3/07
to TiddlyWiki
> I was wondering what the best method would be to add checkboxes to
> turn on and off custom fields.

http://www.TiddlyTools.com/#CheckboxPlugin

can save the checkbox state to any of the following:
* a custom field
* a tag (just like TagglyTagging)
* a cookie option value (chkXXXX),
* an internal (non-cookie) option value ("config.options.xxx" - note
no "chk" prefix = no cookie)

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

david.j....@gmail.com

unread,
Aug 3, 2007, 12:43:47 PM8/3/07
to TiddlyWiki
I have some text (specified in text boxes and Listboxes in edit mode)
that I would like to display in some tiddlers but not others (during
view mode). I would like to be able to toggle the display in edit
mode based off of the state of a checkbox.

What I would like to do is, in Edit mode, have a checkbox (included in
the EditTemplate) make a different CustomField visible/invisible,
where the CustomField is in the ViewTemplate of the Tiddler. So the
checkbox in edit mode basically turns CustomField on and off for a
specific tiddler.

The HideWhenPlugin can be used to hide fields based off of a specific
tag. So using the checkbox plugin to toggle a tag on and off should
in effect toggle the viability of CustomField?

To put the checkboxes in the EditTemplate would I do as you explained
in this post:
http://groups.google.com/group/TiddlyWiki/browse_thread/thread/41de7d1487c937f2/b09b3a80d18f68d5?lnk=gst&q=checkbox&rnum=3#b09b3a80d18f68d5

If the "tiddler" macro is used to 'transclude' the textboxes into the
edit template will each tiddler be able to keep it's own value for the
checkbox state?

I have never used TagglyTagging before, is there a TagglyTagging
plugin or can I just use the checkbox plugin to do what I want?

Eric Shulman

unread,
Aug 3, 2007, 1:14:02 PM8/3/07
to TiddlyWiki
> The HideWhenPlugin can be used to hide fields based off of a specific
> tag. So using the checkbox plugin to toggle a tag on and off should
> in effect toggle the viability of CustomField?

exactly.

> To put the checkboxes in the EditTemplate would I do as you explained

> in this post:http://groups.google.com/group/TiddlyWiki/browse_thread/thread/41de7d...


> If the "tiddler" macro is used to 'transclude' the textboxes into the
> edit template will each tiddler be able to keep it's own value for the
> checkbox state?

Yes, you can place the checkbox definitions into a separate tiddler
and then transclude them into your template using the "tiddler"
macro. In the checkbox syntax, if you omit the tiddlername (or use
the special "here" keyword in place of the tiddlername (e.g.
"[x(tagname)]" or "[x(tagname|here)]"), then the tag is applied to the
current *rendered* tiddler. When the checkbox is transcluded into the
template, it will always refer to the tiddler being rendered, not the
tiddler in which the checkbox *source* was stored.

However, there is another approach that should also work, but doesn't
require transcluding a separate tiddler that holds the checkbox
definitions. First, install this plugin:
http://www.TiddlyTools.com/#WikifyPlugin
then, you can write the following bit of checkbox syntax directly in
your template definition:
<span macro='wikify "[x(tagname)] prompt text"'></span>

> I have never used TagglyTagging before, is there a TagglyTagging
> plugin or can I just use the checkbox plugin to do what I want?

CheckboxPlugin automatically does "TogglyTagging": when the box is
checked, the tag is added to the tiddler, when the box is unchecked,
the tag is removed.

david.j....@gmail.com

unread,
Aug 6, 2007, 3:53:59 PM8/6/07
to TiddlyWiki
I have my TiddlyWiki set up with the WikifyPlugin and everything seems
to be working. However, when I click the checkbox in edit mode it
immediately goes back to view and saves the checkbox state without
giving me a chance to save any text changes that I have made. If I
edit the text and save the tiddler first and then go back and modify
the checkbox state it works fine.

I tired turning the refresh on the check box off by using the
following:
<span macro='wikify "[_(CheckboxPlugin|hideModInfo)
{this.refresh.tagged=this.refresh.container=false}]

When I put in the extra code to turn off the refresh, the refresh
stops but the checkbox state no longer affects the tag. The checkbox
state seems to be saved though.

Eric Shulman

unread,
Aug 7, 2007, 8:02:31 PM8/7/07
to TiddlyWiki
> I have my TiddlyWiki set up with the WikifyPlugin and everything seems
> to be working. However, when I click the checkbox in edit mode it
> immediately goes back to view and saves the checkbox state without
> giving me a chance to save any text changes that I have made. If I
> edit the text and save the tiddler first and then go back and modify
> the checkbox state it works fine.
>
> I tired turning the refresh on the check box off by using the
> following:
> <span macro='wikify "[_(CheckboxPlugin|hideModInfo)
> {this.refresh.tagged=this.refresh.container=false}]
>
> When I put in the extra code to turn off the refresh, the refresh
> stops but the checkbox state no longer affects the tag. The checkbox
> state seems to be saved though.

The first thing to note is that checkboxes **always save their state
as soon as they are clicked**. Therefore, if a checkbox toggles a
tag, that tag change is applied to the underlying tiddler data
immediately, even if the checkbox is being used from an edit template.

After the checkbox state is saved, the affected tagged/tagging and
container tiddlers are automatically refreshed. This works great when
the checkbox is displayed as part of rendered tiddler content (i.e.,
in "view mode"), and the refresh.tagging/tagged/container flags give
you fine-grained control over which tiddler should be refreshed.

Unfortunately, when the checkbox is displayed as part of an edit
template (i.e., "edit mode"), it the triggered refresh event
prematurely terminates the edit session without saving the tiddler
changes, producing the effect you observed.

To correct this, I've updated the refresh logic for checkboxes so that
they no longer trigger a refresh event for any tiddlers that is
currently being edited, so that whatever changes you are making in
that editor are not "stomped on". In addition, if the checkbox
toggles a tag on a tiddler that is being edited, then it will also add/
remove that tag from the "tags:" input field in the tiddler editor, so
that when you subsequently save your tiddler changes, any tags added/
removed by the checkbox will also be saved.

Here's the update (v2.2.5)...
http://www.TiddlyTools.com/#CheckboxPlugin

give it a try and let me know if this works better for you...

HTH,

Reply all
Reply to author
Forward
0 new messages