Issue: Enable numbering on tiddlers created via a Custom Button?

87 views
Skip to first unread message

@TiddlyTweeter

unread,
Aug 11, 2017, 7:43:58 AM8/11/17
to TiddlyWiki
Ciao all

Use Case: A button set-up for writing plain text Tweets (tweetButton). Should be auto-enumerating.The button below works. I based it on The Journal Button. There is ONE issue. Though it produces on-click a new Tiddler titled "Tweet", with the tag "tweet", and the content type "text/plain", it does not auto-add numbers.

What I really want is this ...
  • A number that auto-INCREMENTS by one every time a new "Tweet" Tiddler is created.
  • Ideally I'd like that all new tiddlers titles created by it look like this: "Tweet", "Tweet #0001", Tweet #0002 etc.
  • The leading hashtag and the leading zeros are not essential.

I notice that if I remove title="$(tweetTitleTemplate)$" from my current "tweetButton", below, then it reverts to creating the Title in the standard way, as "New Tiddler", "New Tiddler 1", "New Tiddler 2". etc. = Numbering okay. Wrong Title.


I am unclear IF I can get the behaviour I want for my use case or how to achieve it.


Any help or pointers much appreciated

Best wishes

Josiah



\define tweetButton()
<$button tooltip={{$:/language/Buttons/NewTweet/Hint}} aria-label={{$:/language/Buttons/NewTweet/Caption}} class=<<tv-config-toolbar-class>>>
<$action-sendmessage $message="tm-new-tiddler" type="text/plain"  tags="$(tweetTags)$" title="$(tweetTitleTemplate)$" text="$(tweetText)$"/>
<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
{{$:/core/images/twitter}}
</$list>
<$list filter="[<tv-config-toolbar-text>prefix[yes]]">
<span class="tc-btn-text"><$text text={{$:/
language/Buttons/NewTweet/Caption}}/></span>
</$list>
</
$button>
\end
<$set name="tweetTitleTemplate" value={{$:/config/NewTweet/Title}}>
<$set name="tweetTags" value={{$:/config/NewTweet/Tags}}>
<$set name="tweetText" value={{$:/config/NewTweet/Text}}>
<<tweetButton>>
</$set>
</
$set>
</$set>


ste...@gmail.com

unread,
Aug 11, 2017, 7:58:40 AM8/11/17
to TiddlyWiki
Hi Josiah,

Did you try "action-createtiddler" with the $basetitle attribute, rather than "tm-new-tiddler"? http://tiddlywiki.com/#ActionCreateTiddlerWidget

Cheers,

Stef

@TiddlyTweeter

unread,
Aug 11, 2017, 8:50:13 AM8/11/17
to tiddl...@googlegroups.com
Ciao Stef & all

stef...@gmail.com wrote:Did you try "action-createtiddler" with the $basetitle attribute, rather than "tm-new-tiddler"? http://tiddlywiki.com/#ActionCreateTiddlerWidget

Thanks. Its getting a bit clearer, but I'm not quite there yet.

That worked to complete the titles with correct numbers: "Tweet, Tweet 1, Tweet 2" etc. Unfortunately it doesn't seem to be able to open the new "Tweet" tiddler in the editor. Here is the revised code ...

\define tweetButton()
<$button tooltip={{$:/language/Buttons/NewTweet/Hint}} aria-label={{$:/language/Buttons/NewTweet/Caption}} class=<<tv-config-toolbar-class>>>
<$action-createtiddler $basetitle="$(tweetTitleTemplate)$" type="text/plain"  tags="$(tweetTags)$" text="$(tweetText)$"/>

ste...@gmail.com

unread,
Aug 11, 2017, 10:57:00 AM8/11/17
to TiddlyWiki
Hi Josiah,

You could try something like this:

\define tweetButton()
<$button tooltip={{$:/language/Buttons/NewTweet/Hint}} aria-label={{$:/language/Buttons/NewTweet/Caption}} class=<<tv-config-toolbar-class>>>
<$action-createtiddler $basetitle="$(tweetTitleTemplate)$" type="text/plain"  tags="$(tweetTags)$" text="$(tweetText)$" $savetitle="!!tiddlertitle"/>



<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
{{$:/core/images/twitter}}
</$list>
<$list filter="[<tv-config-toolbar-text>prefix[yes]]">
<span class="tc-btn-text"><$text text={{$:/
language/Buttons/NewTweet/Caption}}/></span>
</$list>
<$action-sendmessage $message="tm-edit-tiddler" $param={{!!tiddlertitle}}/>
</$button>
\end
<$set name="tweetTitleTemplate" value="Tweet">

<$set name="tweetTags" value={{$:/
config/NewTweet/Tags}}>

<$set name="tweetText" value={{$:/config/NewTweet/Text}}>
<<tweetButton>>
</$set>
</
$set>
</$set>

Cheers,

Stef

ste...@gmail.com

unread,
Aug 11, 2017, 11:17:25 AM8/11/17
to TiddlyWiki
Here is my code again, with a small correction:


\define tweetButton()
<$button tooltip={{$:/language/Buttons/NewTweet/Hint}} aria-label={{$:/language/Buttons/NewTweet/Caption}} class=<<tv-config-toolbar-class>>>
<$action-createtiddler $basetitle="$(tweetTitleTemplate)$" type="text/plain"  tags="$(tweetTags)$" text="$(tweetText)$" $savetitle="!!tiddlertitle"/>



<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
{{$:/core/images/twitter}}
</$list>
<$list filter="[<tv-config-toolbar-text>prefix[yes]]">
<span class="tc-btn-text"><$text text={{$:/
language/Buttons/NewTweet/Caption}}/></span>
</$list>
<$action-sendmessage $message="tm-edit-tiddler" $param={{!!tiddlertitle}}/>
<
/$button>
\end

<
$set name="tweetTitleTemplate" value={{$:/config/NewTweet/Title}}>

<$set name="tweetTags" value={{$:/config/NewTweet/Tags}}>
<$set name="tweetText" value={{$:/config/NewTweet/Text}}>

<<tweetButton>>
</$set>
</
$set>
</$set>

Cheers,

Stef

@TiddlyTweeter

unread,
Aug 11, 2017, 4:59:18 PM8/11/17
to TiddlyWiki
Ciao Stef

Unfortunately neither version works for me. They open a new tiddler for editing but the Title is blank :-(

Josiah

ste...@gmail.com

unread,
Aug 11, 2017, 5:42:35 PM8/11/17
to TiddlyWiki

On Friday, August 11, 2017 at 10:59:18 PM UTC+2, @TiddlyTweeter wrote:

Unfortunately neither version works for me. They open a new tiddler for editing but the Title is blank :-(

This is odd... when I copy the first version of my code (in which the value of $basetitle is hard-coded as "Tweet") into tiddlywiki.com, it works out of the box!

Stef

ste...@gmail.com

unread,
Aug 11, 2017, 5:51:54 PM8/11/17
to TiddlyWiki
On Friday, August 11, 2017 at 10:59:18 PM UTC+2, @TiddlyTweeter wrote:

Unfortunately neither version works for me. They open a new tiddler for editing but the Title is blank :-(

Well, must admit that I didn't try using this as a sidebar button. Try replacing both occurrences of "!!tiddlertitle" with "tweetButton!!tiddlertitle". Does this work?

Stef 

ste...@gmail.com

unread,
Aug 11, 2017, 6:13:26 PM8/11/17
to TiddlyWiki


On Friday, August 11, 2017 at 11:51:54 PM UTC+2, ste...@gmail.com wrote:
On Friday, August 11, 2017 at 10:59:18 PM UTC+2, @TiddlyTweeter wrote:

Unfortunately neither version works for me. They open a new tiddler for editing but the Title is blank :-(

Try replacing both occurrences of "!!tiddlertitle" with "tweetButton!!tiddlertitle". Does this work?

Or whatever the title of the tiddler containing the Tweet Button is, of course. 

@TiddlyTweeter

unread,
Aug 12, 2017, 5:14:44 AM8/12/17
to TiddlyWiki
Ciao Stef

ste...@gmail.com wrote:
Try replacing both occurrences of "!!tiddlertitle" with "tweetButton!!tiddlertitle". Does this work?

Many thanks! Its working. Much appreciated.

Best wishes
Josiah
Reply all
Reply to author
Forward
0 new messages