Problems setting title of a newly created tiddler

@Bob_Jansen — What have been the search-terms you used at tiddlywiki.com to search for help?

May be this will help us, to make the information about transclusion modes and “brackets” more visible.

My guess: The quotation marks do what they’re supposed to, i.e they ensure their encapsulated value is literal. But you want it to be evaluated so just remove the quotation marks, i.e:

$basetitle={{$:/TLS/linktitle}}

I’m guessing you intended for the quotation marks to “ensure encapsulation” so you don’t get $basetitle=foo bar (in which case only foo would become the basetitle and the bar would probably mess up the succeeding code) but my interpretation is that the {{ }} by themselves “encapsulate” also it’s evalutated output, so there’s no need for further encapsulation.

(Someone please correct me if I’m twaddling nonsense.)

1 Like

PMario,

Thank you for your email. Your comment about actions being outside buttons would appear to be misleading, as per example 1 of the action-createtiddler page ( https://tiddlywiki.com/static/ActionCreateTiddlerWidget.html). In this example the action is clearly within the button declaration. Also, the first para of the action tiddler page states ‘ Action widgets are used within triggering widgets such as the ButtonWidget.’

As for removing the double quotes around the value of the basetitle attribute, I did that and as explained, it also did not work.

The problem seems to be transcluding a transclusion. This this case, the linktitle tiddler is a transclusion of the incremental tiddler. In this case, the basetitle attribute is transcluding the linktitle tiddler but it is not recognising that the linktitle tiddler involves a transclusion itself.

Bobj

@twMat is spot on here, and in your adventure @Bob_Jansen to understanding quotes and braces there are a number of places where you need only use one form of “encapsulation” or delimiters such as in filters you may have an operator[literal] but then use a field reference operator{!!fieldname} or variable operator<varname> see how we abandon the [ ] brackets?.

  • It uses an extension of the methods used in most languages seen here Literal Attribute Values. As @twMat pointed out quotes are for literals.
  • See Widget Attributes.
  • What tends to dominate is tiddlywikis custom braces { [ <
  • Outside of filters they are doubles so as to not conflict with html {{ [[ << with the exception now of {{{ and newly introduced (inside backticks) $(varname)$ and ${ filter }$

BTW, I don’t think you’re allowed to have space characters around the = but I’m not sure.

1 Like

Tones,

As explained in my original post, I tried using just the transclusion syntax for the basetitle attribute value and it did mot work. I need the new tiddler to be called CS1 in this case and to increment the incremental tiddler so the next time the new tiddler would be called CS2. The incremental code works.

As I explained in my reply to PMario, the problem seems to me to be the transclusion of a transcluded tiddler is not working

Bobj

$basetitle={{{ [{$:/TLS/linktitle}addprefix[CS]] }}}

In 5.3.0

$basetitle=`${ [{$:/TLS/linktitle}addprefix[CS]] }$`

Tones,

Good to talk to you. Will apply your simple suggestion tomorrow.

Bobj

That’s right and the info is outdated. —

I did want to fix that problem at May 10th but the PR got rejected because it was not 100% perfect.

The following link shows the info from the PR-preview, which IMO shows an improved version of that info. ActionCreateTiddlerWidget from PR preview version – not merged

It may not be perfect, but I’m sure it is better than the existing version. Since the first example is for advanced users, I did move it to the end. Now it starts with the more basic examples.

I think, documentation should move fast so it can be incrementally improved, when contributors have time.

Since I did not see a chance to get the PR merged and I did run out of time, I did close the PR.

-m

PMario,

Then maybe there needs to be a business rule that adds a warning to the tiddler in question so as to notify users of the coming change.

Bobj

I was happy to see this “unusedtitle” macro and I want to use it as an input to feed into <$action-createtiddler> it would be a nice add to have separator logic in that action widget. In the absence of that, what’s the best way to use a createtiddler with a different separator in the case that the basetitle is the result of a query? I’m stuck trying to get the logic of this one… Seems like wikify is needed…

I want my basetitle to be something like <<unusedtitle baseName:<<now "YYYY0MM0DD">> separator:"_">> which obviously won’t work, need to get the macro in the macro into something I can put into the actionwidget

1 Like

@stobot you are aware that if you provide a basetitle that already exists it will make it unique by appending a number as for regular new tiddlers? In this case you can use a filtered transclusion to define the name and let it handle clashes?

$basetitile={{{ filter }}}

Yes, unfortunately that’s doing tiebreakers with the space character separator which I’m trying to avoid.

unusedtitle is a useful macro to change the separator but being a macro I can’t feed it a macro as a parameter (like <<now>>) unless I use the macrocall widget but then I can’t save that as a value to feed to createtiddler.

I think I’m forgetting an obvious workflow here

Have you tried my earlier suggestions?

  • If you new name is indeed unique before used in basetitle you will never get the incremented names.
  • You can use macros in filters now {{{ [<now YYYY0MM0DD>] }}}
\define unused-title() <$macrocall $name=unusedtitle baseName=<<now "YYYY0MM0DD">> separator="_"/>

<$wikify name=unused-title text="<<unused-title>>">
<$link to=<<unused-title>>/>
</$wikify>
  • You can always wikify the macro to force it to be evaluated before use
  • If you follow the link and create that tiddler, it will display the next unused title.
  • Put your create tiddler process inside the wikify and use the “redefine/wikified” <<unused-title>>

However I am sure there are better options in 5.3.0

Thanks @TW_Tones, that block of code is what I was struggling to think of! I’ve realized that I could also make use of the counter functionality of <$list> to accomplish a no-space tiebreaker in my specific case but it was bugging me to not remember how to string the macros together (macro into a macro into a parameter).

I emphasise, there are a few areas in tiddlywiki which are tricky to wrap your head around, and even when you know them, if you are little tired, they can be hard to recall.

  • I really do think better solutions are available in 5.3.0 but an unused title operator may help.
  • I will return here if I stumble on something.

Just experimenting, nd Need to strengthen my 5.3.0 knowledge before I can determine an optimum answer.

A Couple of facts;

  • The unusedtitle Macro is a javascript modual, not a traditional macro
  • If you make a procedure containing the macrocall you still need to wikify if for use.
  • In 5.3.0 you can call this macro as if it were a procedure
<$transclude $variable=unusedtitle baseName=`<<now "YYYY0MM0DD">>` template="$baseName$-$count:4$" />
  • But this still not solve our need to use a widget to get a value to give it to a parameter within a widget (except by wikifying at the last moment).

Still researching

[Edited]

As I suspected you can do it with the triple curly braces, ie a “filtered transclusion”, or the new substitution method. In both cases the result should be returned without needing to wikify.

  • In this case I made my own unused title “filter” but it could be made into a function.

See the two examples below;

<$let today=<<now YYYY0MM0DD>> >
{{{ [range[1],[99]] +[pad[2]addprefix[-]addprefix<today>!has[title]] +[first[]]  }}}

`${ [range[1],[99]] +[pad[2]addprefix[-]addprefix<today>!has[title]] +[first[]] }$`


<$button>
<$action-createtiddler $basetitle={{{ [range[1],[99]] +[pad[2]addprefix[-]addprefix<today>!has[title]] +[first[]]  }}} tags="test" text="content">
<$action-navigate $to=<<createTiddler-title>>/>
</$action-createtiddler>
Create 1
</$button>

<$button>
<$action-createtiddler $basetitle=`${ [range[1],[99]] +[pad[2]addprefix[-]addprefix<today>!has[title]] +[first[]] }$` tags="test" text="content">
<$action-navigate $to=<<createTiddler-title>>/>
</$action-createtiddler>
Create 2
</$button>

</$let>

Now I move this filter into a function including remove the need for the today variable and it looks good.

\function next-title() [range[1],[99]] +[pad[2]addprefix[-]addprefix<now YYYY0MM0DD>!has[title]] +[first[]]

<$button>
<$action-createtiddler $basetitle={{{ [function[next-title]]  }}} tags="test" text="content">
<$action-navigate $to=<<createTiddler-title>>/>
</$action-createtiddler>
Create A
</$button>

<$button>
<$action-createtiddler $basetitle=`${ [function[next-title]]  }$` tags="test" text="content">
<$action-navigate $to=<<createTiddler-title>>/>
</$action-createtiddler>
Create B
</$button>
  • Of course you can easily modify the function, even add parameters.
  • Here I solved the complexity with using a widget to provide an attribute value, but not using one, but building my own “unused title” filter/function.

The Question remains what is the best way to use a widget to provide an attribute value?

1 Like

A post was split to a new topic: Use Unusedtitle and Now-macro to Dynamically Define a Unique Name to use with ActionCreateTiddlerWidget

@stobot I did move the info to its own thread, to be able to focus on 1 topic.

@pmario I hope you have looked at the function based solution by me above. I believe it is much easier to follow, and could be improved even further.