refer to recently created tiddler when creating a bunch of tiddlers tagged with the name of that tiddler and whose name are the name of the tiddler with various words appended, or something like that....

42 views
Skip to first unread message

icqol.s...@gmail.com

unread,
Mar 21, 2019, 6:43:54 PM3/21/19
to tiddl...@googlegroups.com
[ 2019 03 23 UPDATE]

I have found a macro tidexist that I can use to test to see if the original tiddler exists, and if not suggest entering a new name instead.

This approach renders the original question moot. The final result is posted at very bottom for future reference.
--
[ORIGINAL POST]

I am creating a button that will create a tiddler and a bunch of tiddlers tagged with the name of that tiddler and whose name are the name of the tiddler with various words appended. 

for example, "Tiddler one" and "Tiddler one - Category one" , with tag: "Tiddler one"

The problem I have is that in this line
<$action-createtiddler $basetitle={{$:/state/new-button-caption}} tags="Workshop createdByButton" text={{$:/plugins/reidgould/dpbd/templates/view/Board}} focus=yes /

I create the tiddler, but if a tiddler with that name, Say "Tiddler One" exists, the actual name of the tiddler with not be 'Tiddler One' but 'Tiddler One 1" (or 2 or 3, if prior ones exist...). This is alright as far as it stands, but now the tags, which are based on  "{{$:/state/new-button-caption}}" will not have the additional number, will all be to the original tiddler, not the newly created tiddler. 

I also had ot use the strange tagme tagx scheme in order to get tiddler names with spaces into the tag, otherwise the name became several tags (for example, if I used "tags={{$:/state/new-button-caption}}" directly). There may be a better way to do this???

Is there any way to fix this? I think I have to update
<$set name=tagx value={{$:/state/new-button-caption}} >
somehow...but how to identify the correct value, i.e. the exact name of the tiddler I just created?

P.S. I cribbed most of the code from other places, and it is well likely that there is a better approach for this or other aspects of it...Thanks in advance.

[OLD CODE, see below for corrected]
\define songs() {{$:/state/new-button-caption}} - Songs
\define games() {{$:/state/new-button-caption}} - Games
\define art() {{$:/state/new-button-caption}} - Art
\define intro() {{$:/state/new-button-caption}} - Intro
\define books() {{$:/state/new-button-caption}} - Books
\define tagme() [[$(tagx)$]]
\define concat(text,1,2,3,4,5,6,7,8,9,10) $text$
\define myTags(title) <<concat "'{{$:/state/new-button-caption}}'" >>
---
<<concat "' {{$:/state/new-button-caption}} '" >>
---
<<myTags {{$:/state/new-button-caption}}>>
---

<$set name=tagx value={{$:/state/new-button-caption}} >

 Title: <$edit-text tiddler="$:/state/new-button-caption" tag="input" default=""/>
<br>
Button below will create a Workshop with the following names and tags:<br>

* {{$:/state/new-button-caption}} tags: Workshop, createdByButton 
* <<songs>> TAGS: "<<tagx>>"
* <<games>> TAGS:  "<<tagx>>"
* <<art>> TAGS:  "<<tagx>>"
* <<intro>> TAGS:  "<<tagx>>"
* <<books>> TAGS:  "<<tagx>>"


----
<<tagme>>
--------

<$wikify name="songs" text=<<songs>> >
<$wikify name="games" text=<<games>> >
<$wikify name="art" text=<<art>> >
<$wikify name="intro" text=<<intro>> >
<$wikify name="books" text=<<books>> >
<$button>

<$action-createtiddler $basetitle={{$:/state/new-button-caption}} tags="Workshop createdByButton" text={{$:/plugins/reidgould/dpbd/templates/view/Board}} focus=yes />


<$action-createtiddler $basetitle=<<songs>> tags=<<tagme>> text="Homemade Button" focus=yes />
New Tiddler
</$button>
</$wikify>
</$wikify>
</$wikify>
</$wikify>
</$wikify>

</$set>



[UPDATED CODE as mentioned in preamble]
\define songs() {{$:/state/new-button-caption}} - Songs
\define games() {{$:/state/new-button-caption}} - Games
\define art() {{$:/state/new-button-caption}} - Art
\define intro() {{$:/state/new-button-caption}} - Intro
\define books() {{$:/state/new-button-caption}} - Books
\define tagme() [[$(tagx)$]]
\define nontidexist(tiddler)
<br>

* Workshop <span class="tagme"> <<tagme>> </span>  does NOT exist. You are GOOD TO GO, Houston!
<br><br>
<hr>

This &nbsp;
<$wikify name="songs" text=<<songs>> >
<$wikify name="games" text=<<games>> >
<$wikify name="art" text=<<art>> >
<$wikify name="intro" text=<<intro>> >
<$wikify name="books" text=<<books>> >
<$button>
<$action-createtiddler $basetitle={{$:/state/new-button-caption}} tags="Workshop createdByButton Board" text={{$:/plugins/reidgould/dpbd/templates/view/Board}} focus=yes />

<$set name=tagx value={{$:/state/new-button-caption}} >
<$action-createtiddler $basetitle=<<songs>> tags=<<tagme>> text="Homemade Button" focus=yes />
<$action-createtiddler $basetitle=<<games>> tags=<<tagme>> text="Homemade Button" focus=yes />
<$action-createtiddler $basetitle=<<art>> tags=<<tagme>> text="Homemade Button" focus=yes />
<$action-createtiddler $basetitle=<<intro>> tags=<<tagme>> text="Homemade Button" focus=yes />
<$action-createtiddler $basetitle=<<books>> tags=<<tagme>> text="Homemade Button" focus=yes />
</$set>
<<tagx>>
</$button>
</$wikify>
</$wikify>
</$wikify>
</$wikify>
</$wikify>

&nbsp; button will create a Workshop with the following names and tags:<br>
<br>
* {{$:/state/new-button-caption}} TAGS: <<tag Workshop>> <<tag createdByButton>> <<tag Board>>
<br><br>
* <<songs>> TAGS: {{$(tagx)$||$:/core/ui/TagTemplate}}<br>
<br>
* <<games>> TAGS: {{$(tagx)$||$:/core/ui/TagTemplate}}<br>
<br>
* <<art>> TAGS: {{$(tagx)$||$:/core/ui/TagTemplate}}<br>
<br>
* <<intro>> TAGS: {{$(tagx)$||$:/core/ui/TagTemplate}}<br>
<br>
* <<books>> TAGS: {{$(tagx)$||$:/core/ui/TagTemplate}}<br>
<hr>

\end
\define tidexist(tiddler)
<$vars tiddler="""$tiddler$""">
<$list filter="[title[$tiddler$]] +[has[title]]" emptyMessage=<<nontidexist """$tiddler$""">>>
<br>
<span class=tagme><<tagme>></span> EXISTS. Overwriting existing tiddler prohibited. Enter new name or click to edit<span class=tagme> [[existing tiddler|$tiddler$]]</span>.
<br><br>
</$list>
</$vars>
\end
<style>
#createAWorkshop  input:not([type]), .tagme  a.tc-tiddlylink {
color: red;
font-family: Arial, non-serif;
font-size:1.2em;
font-weight: 600;
width: 80%;
}
#createAWorkshop  input:not([type]) {
position:relative;
left: 5%;
}
</style>

<div id="createAWorkshop" style="background: lightblue; color:maroon; padding:10px;">

!!!__Create a Workshop__
<$edit-text tiddler="$:/state/new-button-caption" tag=input default="" size=35 placeholder=<<now "YYYY 0MM 0DD Workshop" >>  />  
<$set name=tagx value={{$:/state/new-button-caption}} >
<$reveal text=<<tagx>> type="match" default=""  >
 (enter the date/name of the workshop)
</$reveal>
<$reveal text=<<tagx>> type="nomatch" default=""  >
<br>
<<tidexist $(tagx)$ >>
</$reveal>



<!-- <pre><$view /></pre> -->




icqol.s...@gmail.com

unread,
Mar 22, 2019, 6:20:09 PM3/22/19
to TiddlyWiki
Per forum instructions...original post resolved/updated.
Reply all
Reply to author
Forward
0 new messages