Hide groups of fields in the EditTemplate based on prefix?

121 views
Skip to first unread message

Joshua Fontany

unread,
Jun 27, 2017, 4:35:51 PM6/27/17
to TiddlyWiki
Hi everyone,

I'm back hacking at my RPG Tiddlywiki, and I have a few things figured out (conditional ViewTemplate and EditTemplate stuff).

I'm stuck on how to implement the following:

I have a ton of tiddler fields that are specific to a tiddler type (Player, Character, Location, etc). I have made custom UI to display in a tiddler's ViewTemplate and EditTemplate if it is tagged with one of these core types. The conditional EditTemplate allows editing a formatted set of fields (hiding their field names for more friendly names). These are fields that start like contact.*, character.*, ruleset.*. I would like to hide these specific fields from being displayed at the bottom of the normal EditTemplate.

I understand that the usual way of doing this would be to create a bunch of tiddlers in the namespace:
$:/config/EditTemplateFields/Visibility/*

But, I want to avoid having to track individual tiddlers for fields like that (I intend to have a lot of fields).
----------------
So! How can I edit the $:/core/ui/EditTemplate/fields tiddler so that those fields with prefixes in my list are not displayed? Ideally, with a way to toggle that function so that you can hide or show the "duplaicate" fields in the EditTemplate.

I have something working by storing some Regex in my $:/config/EditTemplateFields/Hidden/prefixes tiddler's text field and editing the Filter in the EditTemplate tiddler from:
[all[current]fields[]] +[sort[title]]
to:
[all[current]fields[]!regexp{$:/config/EditTemplateFields/Hidden/prefixes}] +[sort[title]]


But this means that I have to manage that Regex string myself, which will get unwieldy when that list grows. Currently, for 2 prefixes the Regex looks like:
^contact\.|^ed4\.

And that successfully hides all fields that start with "Contact." or "ed4." But I'm stuck on how to toggle this or manage it going forward.

Any ideas?

PMario

unread,
Jun 27, 2017, 11:58:54 PM6/27/17
to TiddlyWiki
Hi Joshua,

IMO you just need to place your custom fields: contact.*, character.*, ruleset.* into your own namespace.
eg: rpg.character.something, rpg.ruleset.*, rpg.* ... Can you see it?

Now your filter can be: [all[current]fields[]!prefix[rpg.]] +[sort[title]]

short test: <<list-links "[all[current]fields[]!prefix[rpg.]] +[sort[title]]">>

you can have / hide as many custom fields as you want. ... and ... you can have several namespaces too!

If you want to make it as short as possible you can use "_." or even "." as prefixes. ... but I'd go with a 3 letter prefix. It works nicely and has many possibilities.

have fun!
mario

Jed Carty

unread,
Jun 28, 2017, 2:46:50 AM6/28/17
to TiddlyWiki
This isn't directly related to your question, but in my experience it is better to separate the visualisation and data parts. I normally have many data tiddler that have as many fields or indexes as needed and then have one viewer tiddler where you select what you want to view. It lets you decide what is shown and editable and what isn't without having to worry about what is stored in the tiddler you are currently looking at.

Mat

unread,
Jun 29, 2017, 8:00:38 PM6/29/17
to TiddlyWiki
@Joshua, you may peek at my answer (which I believe is exactly what you want) only if you first promise that you'll share something from your final creation that is of joy or benefit to others here ;-)


<:-)

Joshua Fontany

unread,
Jul 2, 2017, 2:42:56 PM7/2/17
to TiddlyWiki
Hi Mat,

That is a really neat solution!

I am doing something similar with tagging to allow a centralized View and Edit Template tiddler to dynamically transclude the appropriate View and Edit templates for each of my "CampaignWiki Tiddler Types" : Player, Character, Company, Faction, Location, Item, etc. So I immediately saw what you were doing, NEAT.

I will definitely post my wiki up once I have some of the base category sheets worked out. Working on Players and Characters first. I intend to seperate the Campaign-logic from the rule-set logic, so Character tiddlers can have multiple ruleset's stats (ed4.strength, ed4.dexterity, ed4.toughness .... d&d1.strength, d&d1.dexterity, D&D1.constitution), and have a tabbed system that allows you to flip through those if you have multiple rulesets "installed". That is a ways down the todo-list, but I have to lay the foundation first.

And this really helped. Thanks!

Joshua Fontany

unread,
Jul 2, 2017, 2:44:37 PM7/2/17
to TiddlyWiki
Hi PMario,

This was one of the possible solutions I was considering. I went with this method to prototype out stuff. It worked well, thanks for the suggestion.

I'm going to combine it with Mat's solution (down thread) for some neat dynamics.

Best,
Joshua
Reply all
Reply to author
Forward
0 new messages