Conditional Export

Sorry if this has been asked before. I’m writing a new export, i.e., $:/tags/Exporter. I wanted it to be conditional. Eg. only if tiddler is [tag[person]].

I added a condition field but I’m unable to get it to work. Adding this field has impacted the export; it no longer appears, but it also does not appear when the tiddler is tagged with person.

I’d appreciate some direction. Thank you.

Craig

I’m not sure I follow. Things with that tag are kinds of export (CSV, JSON, etc.)… Defining a kind of exporter is distinct from specifying a filtered set of tiddlers to export…

Have you already defined your filter, and the question is just how to apply it only to tiddlers defined as persons? In other words, you can already find it in advanced search tab, like this (your export format added to CSV, JSON, HTML)…?

I created a new tiddler, tagged with $:/tags/Exporter. It is a new export, new file extension. It works.

On the tiddler toolbar (above the tiddler in view mode) we have the more icon with its numerous menu items. In that list of menus is export. My new export appears there (along with others), but it appears there for every tiddler. Ideally, I only want my export option to appear if the tiddler is tagged with “person”.

So, having used the condition field for other things, I tried it here, in my export definition tiddler. When I created the field with various filters the export option disappeared. However, I cannot get it behave with the rule I want.

I thought this would work:

[tag[person]]

I’m looking for solution. However, perhaps the condition field is not supported here. But, having questioned it, its behaviour does change when I add it.

Hope this helps,

Craig

The TWCore shadow responsible for displaying the export menu dropdown is here:
https://tiddlywiki.com/#%24%3A%2Fcore%2Fmacros%2Fexport

In that code, you can find this line:

<$list filter="[<currentTiddler>has[condition]subfilter{!!condition}limit[1]] ~[<currentTiddler>!has[condition]then[true]]" variable="ignore">

which uses the !!condition field to determine when a given exporter is included in the dropdown.

Note that the <currentTiddler> value (and thus the {!!condition} field reference refers to the exporter definition tiddler, NOT the tiddler being viewed. To define a condition based on the tiddler being viewed, your condition field needs to reference the <storyTiddler> variable, like this:

[<storyTiddler>tag[person]]

enjoy,
-e

Thank you. This highlighted a few things.

I need to dive deeper into debugging. Seeing condition logic is helpful. I also need to be bit more clearer with my problem statements.

Thanks again,

Craig