I assume you are trying to create a unique identifier for each tiddler
that way?
Have you considered what happens when importing tiddlers into other
documents? You might wanna use GUIDs/UUIDs instead of sequential numbers.
> The counter for the tiddler to be created tiddler is stored in a
> tiddler using the datatiddler plugin. [...] I would rather use
> something like [...] config.options.txtCounter
Well, config.options are stored in cookies - so they depend on the
respective user's browser session, and thus seem unsuitable for this task.
So I'd say storing that data in a tiddler (slice) is the correct thing
to do.
> were can a find info on
> the ......autoNumber.handler=function(...... more specific how does it
> work?
Macro handlers (config.macros.*.handler) are invoked when the respective
macro is being rendered. All handlers are passed the following arguments:
* place: the respective macro call's containing DOM object
* macroName: the respective macro's name
* params: macro parameters as an array
* wikifier: the wikifier object being used
* paramString: macro parameters as a string
* tiddler: the respective macro call's containing tiddler
In contrast, the init function (config.macros.*.init) is executed on
startup and takes no arguments.
I've added this to the community wiki:
http://www.tiddlywiki.org/wiki/Dev:Macros#Macro_Execution
Feel free to improve/correct the information there.
HTH.
-- F.
Hi FND,
By numbering sequential it is easy to sort, and the numbers are
unique, like IDs that are used in databases.
I was also thinking about storing the counter var in the macro itself
and than after the creation of a tiddler rewrite the counter var with
a replace function.
Would be possible I think???
Thanks for the iOkidoOkido
On Sep 9, 12:35 pm, FND <F...@gmx.net> wrote:
> > I use the code below to create sequential numbered tiddlers
>
> I assume you are trying to create a unique identifier for each tiddler
> that way?
> Have you considered what happens when importing tiddlers into other
> documents? You might wannaGUIDsGUIDsUUIDsUUIDs instead of sequential numbers.
>
> > The counter for the tiddler to be created tiddler is stored in a
> > tiddler udatatiddlerdatatiddler plugin. [...] I would rather use
> > something like [...] config.options.txtCounter
config
ell, config.options are stored in cookies - so they depend on the
> respective user's browser session, and thus seem unsuitable for this task.
> So I'd say storing that data in a tiddler (slice) is the correct thing
> to do.
>
> > were can a find info on
> > the ......autoNumber.handler=function(...... more specific how does it
> > work?
>
> Macro handlers (config.macros.*.handler) are invoked when the respective
> macro is being rendered. All handlers are passed the following arguments:
> * place: the respecall'smacro call's containing DOM macroName
* macroName: the respective macroparamse
> * params: macro parameters as awikifier
> * wikifierwikifier: the wikifier oparamString used
> * paramString: macro parameters as a string
> * tiddler:call'sespective macro call's containing tiddler
init
In contrast, the init function (config.macros.*.istartup executed on
> startup and takes no arguments.
>
> I've added this to the community wiki:
> http://www.tiddlywiki.org/wiki/Dev:Macros#Macro_Execution
> Feel free to improve/correct the information there.
>
> HTH.
>
> -- F.
The numbers are unique only as long as the tiddlers are not shared
between documents.
Tony's suggestion of using tiddler.created instead sounds reasonable.
> I was also thinking about storing the counter var in the macro itself
> and than after the creation of a tiddler rewrite the counter var with
> a replace function.
So you want to dynamically modify the respective plugin tiddler to
increment the initialization variable? I don't think that's such a good
idea...
-- F.