[tocP, rewritten-toc] Changing caption field of child branches?

I am using the tocP plugin with the captionField set to toc-caption, but I was wondering if there is a way to override this in children tiddlers, so that if I wanted to just show the title field and not any captionField or the caption.

i.e.

{"title":"Contents" (toc captionField):"toc-caption", "tags":"$:/tags/SideBar"} 
   {"title":"Journal Tiddlers" "toc-caption":"Journal", "tags":"$:/tags/Contents, [[Note Tiddlers]]"} 
   (shows toc-caption)
   {title:"Note Tiddlers", toc-caption:"Notes", tagged:"$:/tags/Contents"} 
   (shows toc-caption)
      {title:"Journal Tiddlers", "toc-caption":"Journal", tagged:"$:/tags/Contents, [[Note Tiddlers]]"}
      (shows title when nested under "Note Tiddlers")

I’ve tried overriding the macro in the “Note Tiddlers” tiddler or using macrocall and setting the captionField to <<caption-field>>, which would be \define caption-field() toc-caption with the “Note Tiddlers” having \define caption-field() title but I wasn’t able to get it to change to show the tiddler as its title, among other things I’ve tried.

bit of a headscratcher, but I’d appreciate any help :sweat_smile:

There is a viewField parameter that you can change to title. IMO this should do the trick. — The setting is global

I’m having a bit of a hard time understanding how to use the viewField parameter in this circumstance.

as an addendum, I’m using the following in my contents tiddler, rather than the tocP macros as I only needed the ability to sort using filter rather than tags.

How exactly would I have the viewField parameter in the Contents tiddler and then have it set to title for children tiddlers?

\define tv-toc-show-new-child() yes

<div class="tc-table-of-contents">
<<toc-selective-expandable tag:"Contents" field:"toc-filter" captionField:"toc-caption">>
</div>

I tried to do the following to see if it would work, more or less a hail mary…

"title":"Note Tiddlers"
"text":"""
\define tocP-viewfield(viewField:"title")
\whitespace trim
<span class="tc-toc-caption" title={{!!tooltip}}>
<$set name="tv-wikilinks" value="no">
	<$transclude tiddler={{{ [<__viewFieldTemplate__>!is[blank]then<__viewFieldTemplate__>else<currentTiddler>] }}}
		field=<<__viewField__>>
	>
		<$view field="title"/>
	</$transclude>
</$set>
</span>
\end
"""

i remember trying out tocP required me to use a modification to $__core_macros_toc.json (23.2 KB) and now I’m not sure if it is actually apart of the plugin :sweat_smile: (apologies if I’m being a bit dense. unfortunately I’m a bit low on sleep)

That’s not the case. tocP is completely independent of the core toc.

You do not need the title: NoteTiddlers. You can specify the viewField parameter. tocP does not have a captionField parameter. Have a closer look at the docs

You need to call tocP like this.

<div class="tocp tc-table-of-contents">
<<tocP-selective-expandable tag:"Contents" viewField:"title">>
</div>

That should do the trick. There is no need to overwrite the tocp-viewFieldmacro, if the default viewField parameter should be different.

Hope that helps.
-m

It seems you use the unpublished rewritten-toc macro here. The main problem with this one is “missing documentation”.

It should be possible to use rewritten-toc instead of the tocP macro. — I will have a closer look.

1 Like

That makes a lot more sense, I thought it was odd that only part of the plugin was denoted with tocP, my appologies!