if it helps a few thoughts;
I like to think of objects - they have a definition and instances of them.
All you need is a way to indicate a tiddler is an object eg a tag or custom
field object-type="book".
next you have a tiddler in the view template that responds to the existence
of the object-type field and it's content;
<$list filter="[all[current]get[object-type]] variable=object-type>
every object eg; edit mode switch
<$list filter="[<object-type>match[book]]">
handle books here
</$list>
<$list filter="[<object-type>match[author]]">
handle authors here
</$list>
</$list>
On this example the Template is the logic in the ViewTermplate, this makes
it easy to add a new field to all tiddlers of a given object type when they
are displayed.
You can also create A new tiddler button that adds the required fields in
one click as you create a new instance of the object.
Regards
Tones
On Saturday, 17 April 2021 at 06:51:41 UTC+10 si wrote:
> Very nice Anders, thank you. Is the standardtext field necessary? Why not
> just have a tiddler $:/view/book which can be transcluded via a
> ViewTemplate onto any tiddler with tiddlertype=book?
>
> On Friday, 16 April 2021 at 13:20:51 UTC+1 Anjar wrote:
>
>> Hi Si,
>>
>> Thank you for clarification; however, I think the approach is still valid
>> and demonstrated how it works, and with minor adjustments you can have
>> field templates across source types;
>>
>> (1) Make tiddlers with
>> - title starting with "$:/template",
>> - a field tiddlertype, for example tiddlertype: book,
>> - a field standardtext, for example standardtext: {{||$:/view/book}}, and
>> - required (empty) fields, for example booktitle and genre
>>
>> (2) Make
>> - title starting with "$:/fieldtemplate", and
>> - text with how the field should be edited, eg.
>> -- A tiddler $:/fieldtemplate/booktitle with text: Title: <$edit-text
>> field="booktitle" />
>> -- A tiddler $:/fieldtemplate/genre with text: Genre: <$select
>> field="genre"><option>Horror</option><option>Poetry</option><option>Screenplay</option></$select>
>>
>> (3) The add/edit tiddler can be
>> \define tiddlername() {{!!tiddlertype}}: <<now "YYYY-0MM-0DD 0hh:0mm:0ss"
>> >>
>> \define fieldtiddler() $:/fieldtemplate/$(currentFieldTiddler)$
>>
>> <$list filter="[title[$:/temp/edit]!has[text]]">
>> <$list filter="[prefix[$:/template]]">
>> <$button>
>> <$wikify name=newtiddlername text=<<tiddlername>> >
>> <$action-createtiddler $basetitle=<<newtiddlername>>
>> text={{!!standardtext}} tiddlertype={{!!tiddlertype}} />
>> <$action-setfield $tiddler="$:/temp/edit" text=<<newtiddlername>> />
>> </$wikify>
>> Create {{!!tiddlertype}} Tiddler
>> </$button>
>> </$list>
>> </$list>
>> <$list filter="[title[$:/temp/edit]has[text]get[text]]"
>> variable="edittiddler">
>> <$set name=tiddlertype filter="[title<edittiddler>get[tiddlertype]]">
>> <$list
>> filter="[prefix[$:/template]tiddlertype<tiddlertype>fields:exclude[list
>> title text tags created modified]]" variable="currentFieldTiddler">
>> <$tiddler tiddler=<<edittiddler>> >
>> <$transclude tiddler=<<fieldtiddler>> mode="block"/>
>> </$tiddler>
>> </$list>
>> </$set>
>> <$button>
>> <$action-deletetiddler $tiddler="$:/temp/edit"/>
>> Ok
>> </$button>
>> </$list>
>>
>> Now, the form is populated with the corresponding fieldtemplates derived
>> from the fields in the tiddler template. If the same field name is used in
>> another tiddler template, the same field template is used
>>
>> I provide a working example so that you, but most importantly others who
>> perhaps is searching for similar solutions, can test and play around
>>
>> Best,
>> Anders
>>
>> fredag 16. april 2021 kl. 13:18:39 UTC+2 skrev si:
>>
>>> @Anders The disadvantage of your approach is that you have to manually
>>> create a form for every type of source, many of which will share fields
>>> with one another. The reason I asked about the best way to associate
>>> source-types with their required fields is to avoid this problem. If you
>>> know which fields you want for a particular source-type, it should be
>>> possible to automatically generate a form/table for adding new sources.
>>> Just to be clear I wasn't asking for help on how to actually generate the
>>> forms, just on the best way to associate source-types with their required
>>> fields.
>>>
>>> @Sjaak Your point did occur to me, though I am not sure that I will
>>> personally need any different data-entry-methods. I think it would be
>>> possible to add the information about how the data for a field should be
>>> entered within the tiddler that represents the field itself. For example
>>> "Book" could in some way be associated with a tiddler representing the
>>> field "format". Then the "format" tiddler could have its own field
>>> containing something like
>>> <$select><option>Paperback</option><option>Hardback</option></$select>.
>>> This should give you enough information to generate forms with custom
>>> data-entry-methods, and apply them to any source-type without having to
>>> re-write any code.
>>>
>>> On Thursday, 15 April 2021 at 23:40:59 UTC+1 Anjar wrote:
>>>
>>>> Hei Sjaak,
>>>>
>>>> I think a similar approach can be useful;
>>>>
>>>> (1) Make tiddlers with
>>>> - title starting with "$:/template",
>>>> - a field tiddlertype, for example tiddlertype: book, and
>>>> - a field standardtext, for example standardtext: {{||$:/view/book}}
>>>>
>>>> (2) This time, the template contains the form you want to use, for
>>>> example, $:/template/book can contain
>>>> |Composer: |<$edit-text field="composer" /> |
>>>> |Title: |<$edit-text field="musictitle" /> |
>>>> |Genre: |<$select
>>>> field="genre"><option>Horror</option><option>Poetry</option><option>Screenplay</option></$select>
>>>>
>>>> |
>>>>
>>>> (3) Make a new tiddler with the content:
>>>> \define tiddlername() {{!!tiddlertype}}: <<now "YYYY-0MM-0DD
>>>> 0hh:0mm:0ss" >>
>>>>
>>>> <$list filter="[title[$:/temp/edit]!has[text]]">
>>>> <$list filter="[prefix[$:/template]]">
>>>> <$button>
>>>> <$wikify name=newtiddlername text=<<tiddlername>> >
>>>> <$action-createtiddler $basetitle=<<newtiddlername>>
>>>> tiddlertype={{!!tiddlertype}} text={{!!standardtext}} />
>>>> <$action-setfield $tiddler="$:/temp/edit" text=<<newtiddlername>> />
>>>> </$wikify>
>>>> Create {{!!tiddlertype}} Tiddler
>>>> </$button>
>>>> </$list>
>>>> </$list>
>>>> <$list filter="[title[$:/temp/edit]has[text]get[text]]">
>>>> <$tiddler tiddler=<<currentTiddler>> >
>>>> <$set name=edittitle
>>>> filter="[prefix[$:/template]tiddlertype{!!tiddlertype}]">
>>>> <$transclude tiddler=<<edittitle>> mode="block"/>
>>>> </$set>
>>>> </$tiddler>
>>>> <$button>
>>>> <$action-deletetiddler $tiddler="$:/temp/edit"/>
>>>> Ok
>>>> </$button>
>>>> </$list>
>>>>
>>>> The latter tiddler will be your interface and new tiddlers are added in
>>>> the background. They will have the standardtext as text, and you edit them
>>>> directly from the interface tiddler using the form from the template
>>>> tiddler
>>>>
>>>> Best,
>>>> Anders
>>>>
>>>> torsdag 15. april 2021 kl. 20:55:29 UTC+2 skrev [email protected]:
>>>>
>>>>> Hi Si,
>>>>>
>>>>> I have been thinking about an approach like yours but have not
>>>>> implemented anything yet. It seems important to me that some fields may
>>>>> be
>>>>> of a different kind than just text to be entered. Like choosing from a
>>>>> list
>>>>> of options (with f.i. the select widget or radio widget).
>>>>> My 2 cts.
>>>>>
>>>>> Greetings,
>>>>> Sjaak
>>>>>
>>>>> On Thursday, April 15, 2021 at 4:27:48 PM UTC+2 Anjar wrote:
>>>>>
>>>>>> Hi Si,
>>>>>>
>>>>>> Have a look at this post:
>>>>>> https://groups.google.com/g/tiddlywiki/c/Q3vU6tnPffI/m/WNguU1p6BwAJ
>>>>>>
>>>>>> It's about using premade templates to create new tiddlers; you can of
>>>>>> course add a form if you prefer that, instead of editing the new tiddler
>>>>>> directly
>>>>>>
>>>>>> Best,
>>>>>> Anders
>>>>>>
>>>>>> torsdag 15. april 2021 kl. 16:06:52 UTC+2 skrev si:
>>>>>>
>>>>>>> @Springer Thanks for your reply.
>>>>>>>
>>>>>>> >>> The lovely thing is that you can filter on a tag (or any other
>>>>>>> filter condition), to see a column for each of the fields you care
>>>>>>> about
>>>>>>> for that tag (or filter condition), with a row for each tiddler that
>>>>>>> fits
>>>>>>> the condition (and the ability to "clone" new rows into existence).
>>>>>>>
>>>>>>> How do you tell TiddlyWiki which fields to associate with each
>>>>>>> reference-type? So for example you were to add a tiddler with the tag
>>>>>>> "Book", you would want your table to give you the option to add fields
>>>>>>> like
>>>>>>> "author", "title" etc. If you had a tiddler tagged "Movie" you might
>>>>>>> want
>>>>>>> "director", "year" etc. My question is about the best way to associate
>>>>>>> a
>>>>>>> particular type of source with the particular fields that it requires.
>>>>>>> On Wednesday, 14 April 2021 at 21:10:07 UTC+1 springer wrote:
>>>>>>>
>>>>>>>> Si, I highly recommend checking out all the RefNotes resources
>>>>>>>> (active here recently, contributed by Mohammad).
>>>>>>>>
>>>>>>>> My own approach is to use a DYNAMIC TABLE (Mohammad's Shiraz) for
>>>>>>>> each reference-type. The lovely thing is that you can filter on a tag
>>>>>>>> (or
>>>>>>>> any other filter condition), to see a column for each of the fields
>>>>>>>> you
>>>>>>>> care about for that tag (or filter condition), with a row for each
>>>>>>>> tiddler
>>>>>>>> that fits the condition (and the ability to "clone" new rows into
>>>>>>>> existence). Then you don't have a separate challenge of generating
>>>>>>>> forms.
>>>>>>>> Unless you really want to. ;)
>>>>>>>>
>>>>>>>> -Springer
>>>>>>>> On Wednesday, April 14, 2021 at 3:03:02 PM UTC-4 si wrote:
>>>>>>>>
>>>>>>>>> I use TiddlyWiki to manage sources (books, movies etc), and I want
>>>>>>>>> to create an easy way to add tiddlers for individual sources.
>>>>>>>>>
>>>>>>>>> I have decided to add tiddlers that represent a "source-type", and
>>>>>>>>> then use it to generate a form that allows me to enter metadata for a
>>>>>>>>> new
>>>>>>>>> source. For example I might have a source type "Book", which is used
>>>>>>>>> to
>>>>>>>>> generate a form like this:
>>>>>>>>>
>>>>>>>>> Title: ...
>>>>>>>>> Author: ...
>>>>>>>>> Year: ...
>>>>>>>>>
>>>>>>>>> While "Movie" might have a form like this:
>>>>>>>>>
>>>>>>>>> Title: ...
>>>>>>>>> Director: ...
>>>>>>>>> Producer: ...
>>>>>>>>>
>>>>>>>>> Obviously I need to associate the required metadata-fields with
>>>>>>>>> their source-type. I can think of two ways to do this:
>>>>>>>>>
>>>>>>>>> - Add a field to each tiddler type called "required-fields"
>>>>>>>>> which lists the required metadata-fields.
>>>>>>>>> - Create separate tiddlers for each possible metadata-field,
>>>>>>>>> then tag them with any source-type that requires them.
>>>>>>>>>
>>>>>>>>> It's not obvious to me that there is any functional difference
>>>>>>>>> between these two options, but if I make a bad choice it will be
>>>>>>>>> difficult
>>>>>>>>> to change down the line. So my question is: *Is there a reason
>>>>>>>>> that one of these approaches is better than the other?*
>>>>>>>>>
>>>>>>>>> Thanks in advance for you help.
>>>>>>>>>
>>>>>>>>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/390c8b77-1f74-4eef-ac39-651509595cedn%40googlegroups.com.