Macro working well, but not when Tiddler viewed in Sidebar - Problem with CurrentTiddler Variable

112 views
Skip to first unread message

NT

unread,
Sep 7, 2016, 9:09:57 AM9/7/16
to TiddlyWiki
Hey coding folks :)

I have put the well-known TOC-Macrocall

<<toc-selective-expandable 'TOC'>>

into another WikiText Macro


\define toctoc()
"""
<div class="
tc-table-of-contents">
<$macrocall $name="
toc-selective-expandable" tag=<<currentTiddler>>/>
</div>
"""

\end

and then put the call for that one in a tiddler and just calling

<<toctoc>>

then.
I have done this, because
- I found it was two much code, especially with the div formatting around, if you use it again and again for many different tiddlers
- I don't wanted to write the titel of the tiddler manually, every time
- In the future I want changes to be simple, so I can just change my macro and not every tiddler

So this macro is working fine in the tiddler! But!
The TOC doesn't show up, when I view the tiddler in the Sidebar by tagging it with $:/tags/SideBar  - but the rest of normal Text inside the tiddler shows up there.

So, what is wrong? I tested, and when I replace the <<currentTiddler>> Variable for the tag with an actual tag like 'Chapter 12' it is working fine in the Sidebar!

I also tried it in the form of

\define toctoc()
<div class="tc-table-of-contents">
<<toc-selective-expandable """$(currentTiddler)$""">>
</div>
\end

with no results as well.

So again, the problem seems to be the CurrentTiddler Variable, in clear Text (what makes no sense for a macro) it is working well in the Sidebar.
How can I make it work in the Sidebar with the CurrentTiddler Variable?

Thanks for attention :)

Tobias Beer

unread,
Sep 7, 2016, 2:27:35 PM9/7/16
to TiddlyWiki
Hi NT,

What would you think the <<currentTiddler>> to be in the sidebar?
Of course, you'll have to use a macro parameter.

Best wishes,

Tobias. 

NT

unread,
Sep 7, 2016, 5:25:41 PM9/7/16
to TiddlyWiki
Ok Tobias, I think you want to point out that the context / scope of the <<currentTiddler>> Variable changes, if you show the tiddler in the sidebar.
This was not my assumption. I assumed that the context of the Variable is the tiddler and the tiddler is only presented in another "view" - I mean the tiddler just got a tag ($:/tags/SideBar), nothing more.
But as I understand you right the variable changes the scope from the tiddler to the sidebar - which is unexpected to me.

So - QUESTION - there is really no other way than

1. Call the macro with an explicit tiddler title as paramter like

<<toctoc "Chapter 12">>

to

\define toctoc(tiddler:<<currentTiddler>>)
"""
<div class="
tc-table-of-contents">
<$macrocall $name="
toc-selective-expandable" tag=$tiddler$/>
</div>
"""

\end

OR

2. Do it the way I have done it before without explicit tiddler naming, but don't put the macro-calling-tiddler itself to the sidebar but another tiddler with a transclusion of the macro-calling-tiddler inside. Then it works, I have tried.

??? QUESTION END.

For me both alternatives are not really "beautiful" - but ok, they work.
Clarification would be nice, especially about the scope, also the behavior in other contexts. I did not find really detailed information about that here
http://tiddlywiki.com/#currentTiddler%20Variable:%5B%5BcurrentTiddler%20Variable%5D%5D%20%5B%5BMacro%20Definitions%20in%20WikiText%5D%5D%20%5B%5BMacro%20Definition%20Syntax%5D%5D%20Variables%20%5B%5BVariables%20in%20WikiText%5D%5D%20%5B%5BMacro%20Calls%20in%20WikiText%5D%5D
which were matching my usecase.

Tobias, thanks for pushing me into the right direction!

Mark S.

unread,
Sep 7, 2016, 6:31:11 PM9/7/16
to TiddlyWiki
If you have 10 tiddlers open, how would something in the sidebar know which one is "the" tiddler you want?

If you want the TOC in every tiddler, you can add it as part of the view template.

If you want the TOC in certain tiddlers (tagged a certain way, perhaps) you can add it wrapped in a context <$list> so it only appears when wanted.

If you actually want the TOC in the sidebar, then maybe (not sure on this point) you could have a button in your tiddlers that you click and which sets a configuration tiddler which the macro could use to know which one you want to currently use.

-- Mark

Tobias Beer

unread,
Sep 8, 2016, 1:00:32 AM9/8/16
to tiddl...@googlegroups.com
Hi Mark,
 
If you have 10 tiddlers open, how would something in the sidebar know which one is "the" tiddler you want?

For example, by having some mechanism like the live mode in TiddlyMap that detects what is scrolled into view.

Best wishes,

Tobias. 

Eneko Gotzon

unread,
Sep 8, 2016, 6:05:58 AM9/8/16
to tiddl...@googlegroups.com
​Please, excuse these kind of questions.

On Thu, Sep 8, 2016 at 12:31 AM, 'Mark S.' via TiddlyWiki <tiddl...@googlegroups.com> wrote:
If you want the TOC

​Please, what is TOC​?

​Thank you.

--
Eneko Gotzon Ares
eneko...@gmail.com

Mark S.

unread,
Sep 8, 2016, 9:03:25 AM9/8/16
to TiddlyWiki
Table Of Contents

See: "http://tiddlywiki.com/#Adding a Table of Contents to the Sidebar" Link
Reply all
Reply to author
Forward
0 new messages