Thank you so much Eric! Really thank you so much! I'm a little happy to see I was kind of heading in the right direction at one point earlier, except I put the \end of the tocscript define below the </$tiddler> because I was afraid it wouldn't include itself in the button code and it broke it lol. Also thank you very much for providing the explanations as well!
The !!storyname was actually left over from the step before this one. I hadn't considered having a dynamic toc at first. Though now I'll use it in the tocscript to help identify the page a bit better. Thank you for looking that closely at the script! On Wednesday, June 9, 2021 at 2:05:23 PM UTC-4 Eric Shulman wrote: > On Wednesday, June 9, 2021 at 9:53:36 AM UTC-7 iamdar...@gmail.com wrote: > >> I can't figure out how to: >> > 1) Make the toc div text a variable, named tocscript, to call it in the >> script like the fields, so I can add it to the new tiddler being created. >> > > Move the toc div text into a macro named "tocscript". Macros are > essentially variables that can accept parameters. > > 2) Update the tag name in the toc-selective-expandable macro before it is >> added to the new tiddler being created. >> > > Within a macro, there are two forms of syntax that are automatically > replaced when the macro is processed: > * instances of $paramname$ are replaced by corresponding values that are > passed to the macro as parameters > * instances of $(varname)$ are replaced by corresponding values that are > defined in variables before the macro is invoked > > Thus, for your purposes: > \define temp() $:/temp/input/$(currentTiddler)$ > > \define tocscript() > <div class="tc-table-of-contents"> > <<toc-selective-expandable "$(storyabbrev)$" "sort[title]">> > </div> > \end > > | Story Name:|<$edit-text tiddler=<<temp>> field="storyname"/> | > | Story Abbreviation:|<$edit-text tiddler=<<temp>> > field="storyabbrev"/> | > > <$tiddler tiddler=<<temp>>> > <$button> Create Story > <$vars storyabbrev={{!!storyabbrev}}> > <$action-setfield $tiddler={{!!storyabbrev}} text=<<tocscript>> > tags="Stories" /> > <$action-setfield $tiddler={{{ [{!!storyabbrev}addsuffix[ Chapter 001]] > }}} tags={{!!storyabbrev}} /> > <$action-deletetiddler tiddler=<<temp>> /> > </$vars> > </$button> > </$tiddler> > > Notes: > * The $vars widget fetches the !!storyabbrev input value to turn it into a > variable named "storyabbrev", so that it can then be automatically replaced > in the tocscript macro > * I don't see anywhere that you actually use the "!!storyname" input value > > enjoy, > -e > -- 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 tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/a7dccc35-3aa2-49a3-b328-642d5ec92e5bn%40googlegroups.com.