How to create a field macro similar to the tag macro

Your textcolour is missing the colour in the colour macro.

textcolour:<<colour tag-foreground>> id ...

However, even with this adjusted, it doesn’t work for me for some reason.

Edit: oddly, it works fine in a blank tiddlywiki, I wonder if it’s just something with my peronal one, anyhow nevermind!

Edit 2: nevermind my nevermind.

I added it later to the code after posting the message. It was a copy paste error.

Even in my personal wiki it’s not working

ATM I’m taking apart $:/core/macros/tag to see if I can reuse it to apply color and contrastcolour, but it’s a bit harder than I thought it would be.

It looks like the filter-pill macro isn’t getting it’s colors for the palette when using the colour macro, why I do not know.

I wasn’t successful in figuring out how to get it to work, unfortunately.

Thank you @EricShulman .

The ‘qualify’ macro is definitely needed to keep two popups from happening when they are in different tiddlers.

As to your point regarding the “id”, I completely see what you intend with that and agree that it should be necessary. However, it doesn’t seem to matter (at least in Chrome). Putting a bunch of the filter-pill macros together in the same tiddler only pops up the one activated and the others stay closed. I don’t know why since they are all tied to the same state tiddler.

/Mike

Without the “id” params in the <<filter-pill ...>> macro calls, all three popups DO appear. However, they are all displayed at the same position, so they overlap with each other, which can make it appear as if only one popup is being shown.

Thank you for pointing that out. Those duplicates are hidden well.

On that note, I wanted to try to make a unique identifier macro to plug in as a default value. Absent a random number generator, I came up with:

{{{[<now YY0MM0DD0hh0mm0XXX>sha256[]]}}}

Not perfect but has some hope of working if rendering is slow enough.

However, I am noticing that no matter if I define a macro and use it like this

\define filter-pill(pill_filter pill_label:"FilterPill Label" pillcolour:lightgrey textcolour:#333333 id:<<uid>>) ...

or put it directly in like this:

\define filter-pill(pill_filter pill_label:"FilterPill Label" pillcolour:lightgrey textcolour:#333333 id:{{{[<now YYYY0MM0DD0hh0mm0XXX>sha256[]]}}}) ...

The result is using it as a literal string rather than calculating the value and using that. Is it possible to provide anything as a default value to a macro other than a literal string?

@EricShulman Is it possible to get the number of tiddlers for filter next to the export button by using the count operator ?

This is the code I am using.

\define filter-pill(pill_filter pill_label:"FilterPill Label" pillcolour:<<colour tag-background>>textcolour:<<tag-foreground>> id)
<$let popupID=<<qualify """$:/temp/state/$pill_label$$id$""">>>
<$button dragFilter="$pill_filter$" class="tc-tag-label tc-btn-invisible" style="background-color:$pillcolour$; color:$textcolour$;" popup=<<popupID>> >$pill_label$
</$button>
<$reveal type="popup" state=<<popupID>> >
<div class="tc-drop-down">
<$button> export <$count filter="$pill_filter$"/>
<$action-sendmessage $message="tm-download-file"
   $param="$:/core/templates/exporters/JsonFile"
   exportFilter="$pill_filter$"
   filename="tiddlers.json" /> 
</$button>
<hr>
{{{$pill_filter$}}}
</div>
</$reveal>
\end

I used the count widget to get the number of tiddlers in that filter expression.
Is there any way to make this count widget appear in the pill label.

I just want to add as I said previously;

So I am working to extend this Idea for “filter pills” further including;

  • Extensibility like with the use of $:/tags/TagDropdown on tagpills
    • Eg open all/ close all listed tiddlers
    • Search with filter
    • And a lot more

Please let me know what other ideas you have that would make sense on a “filter pill”

1 Like

I’m sure adding the count to the filter-pill can be done. At one point I was hacking regular tag pills to include a count, but benwebber’s tag-count does it better.

Whatever is going on there ought to be readily adapted…

-Springer

If you look at the bottom of Control Panel > Info > Basics we already have the count and click to search. I have adapted this to be included in the improved Filter Pill which is extencible like the tag pills,

So far its looking like this;

<<filter-pill "[all[tiddlers]prefix[b]!sort[]]" >>

You can a label rather than display the filter,

I am, keen for people to make suggestions and I will implement them now.

Hm, I see the count of tags (how many tags there are) in the Control Panel > Info > Basics (and I love the reminder that each of these has a button to zip over to Advanced Search for the details) but – if you were replying to my post – the idea that a filter-pill would display the count of items-thus-filtered within the pill itself (like the tag-count plugin does for tag pills) is different. (I do see that the count is available in your drop-down, and I’m loving the variety of PSaT dropdown features you’ve developd!) Sometimes the ability to see the number right in the pill is a huge efficiency factor!

I love that you have both the ability to display the actual filter (with the filter icon!), AND the ability to specify a label instead. I’m going to want to use this tool!

1 Like

I will see if I can incorporate that, as an option, thanks for the Idea.

1 Like

One thing I’d love – for both the filter-pill and the regular tag-pill dropdowns (and for nearly all plugins and tools, actually), is a clear way to flag elements that should appear only in author mode. (Or alternately, a clear way to flag elements that should be display:none; in read-only css.) Typically for my purposes, PSaT dropdown’s “open all” might be helpful to read-only viewers of a site, while the other tools I would limit to my own authoring / troubleshooting access. For site visitors who know little about the mechanics of tags and filters (and can’t edit them anyway) I’d want to minimize visual “noise” above the main tiddler list.

This sounds like an approach I take where I define a display-filter for example;

<$list filter="[{$:/config/author-mode}match[yes]]" variable=~>
   optional content for authors
</$list>
  • The question do we do a display-filter test inside or outside the elements, or in each of the dropdown items?

Keep in mind a filter-pill can also use a [tag[tagname]] filter such as [tag[todo]!tag[done]] and a label of tagname, so it starts to look like a filtered “tag pill”.

I have added the count on the filter-pill you can override with show-count:"no"

Snag_18f3fd3

@TW_Tones Is your most developed version of filter-pill, with the beautiful icon and all, previewed in image form here…
Snag_18f3fd3
… available somewhere as a plugin or demo site, so that we can neatly link to it and be sure we have the latest and most complete version?

This is the kind of thing for which I’m happy to toss some coins in your hat, and would encourage others to do the same. Your contributions have really enhanced what TW can do! :wink:

-Springer

I will review this today

1 Like

@Springer

I found a newer version, and I surprised myself how good it is, It allows a pill similar to a tag pill but driven by a filter, and with lots of options on the tag pill.

However since filters are more general in nature you can;

  • Create ANY filter pill
  • Reproduce tag pills
  • A custom tag pill (with label)
  • Create field pills

Snag_5df539

Here is the current Version as requested, but I think I will package this and start a new thread to promote it.

filter-pills.json (11.5 KB)

This is a result of a number of contributors which I extended even further.

5 Likes

4 posts were split to a new topic: Using Variable-substitution Within Filter Strings