How Do I get the number of current tiddlers’s field which with the same field value abc
Hi luckyboy, Welcome to the forum.
You will need the following Filter Operators:
- all
- fields
- get
- match
- join
- :filter … Named filter operato
\define excluded() created text draft.title tags title draft.of modified
\function search-term() [{$:/temp/search-term}trim[]]
search-term: <$edit tag=input tiddler="$:/temp/search-term"/>
The `+[join[, ]]` is only there for us humans to make the lists easier to read.
This gives you a cleaned ''field-list'': {{{ [all[current]fields:exclude<excluded>] +[join[, ]] }}}
This shows a list of field ''values'': {{{ [all[current]fields:exclude<excluded>] :map[<..currentTiddler>get<currentTiddler>] +[join[, ]] }}}
This shows a ''filtered field-list'' of values that match the search term: {{{ [all[current]fields:exclude<excluded>] :filter[<..currentTiddler>get<currentTiddler>match<search-term>] +[join[, ]] }}}
This will ''count the fields'', that exactly match the "search-term" variable {{{ [all[current]fields:exclude<excluded>] :filter[<..currentTiddler>get<currentTiddler>match<search-term>] +[count[]] }}}
You can download this attachment and drag & drop import it into tiddlywiki.com for testing.
test-field-filter.json (1.1 KB)
have fun!
Mario
1 Like
Thank you very much ,you remind me to use :filter,i haven’t use it before,it’s powerful,it’s help solve my problem perfectly