Listing a subset of the current tiddlers tags

272 views
Skip to first unread message

TonyM

unread,
Jul 6, 2012, 1:51:56 AM7/6/12
to tiddl...@googlegroups.com
Hi everyone,

I was just wondering if anyone had found a way to list a subset of the current tiddlers tags using a search ?

I have some tiddlers that are tagged with a range of tags to define its type or status including one or more projects for which this tiddler is relevant.

I would like a method to search all tags in the current tiddler then test if the tiddlers these tags represent meet some condition such as being tagged "project". I want a list (ideally on a single line) of the tags in the current tiddler that are project tags.

In this case each tag is also a tiddler with its own tags.

This would be very useful in a number of ways including providing toggle tags and other features for selected tags.

Thanks in advance for considering this request.

TonyM

Eric Shulman

unread,
Jul 6, 2012, 5:35:16 AM7/6/12
to TiddlyWiki
Try this (untested) inline script:

<script>
var out=[];
for (var i=0; i<tiddler.tags.length; i++) {
var tid=store.getTiddler(tiddler.tags[i]);
if (tid && tid.isTagged("project")
out.push("[["+tiddler.tags[i]+"]]");
}
return out.join(" ");
</script>

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

WAS THIS ANSWER HELPFUL? IF SO, PLEASE MAKE A DONATION
http://www.TiddlyTools.com/#Donations
Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
http://www.TiddlyTools.com/#Contact

TonyM

unread,
Jul 6, 2012, 9:09:51 PM7/6/12
to tiddl...@googlegroups.com
Thanks Eric,

I really must stop trying to make the world sustainable and spend some time learning Javascript.

Great that works with an additional ) after condition - ("project")) <- here


<script>
var out=[];
for (var i=0; i<tiddler.tags.length; i++) {
   var tid=store.getTiddler(tiddler.
tags[i]);
   if (tid && tid.isTagged("project") )

      out.push("[["+tiddler.tags[i]+"]]");
}
return out.join(" ");
</script>

Best wishes, TonyM

TonyM

unread,
Jul 6, 2012, 9:17:00 PM7/6/12
to tiddl...@googlegroups.com
One more step - I will try and work out myself,

As I am automating this I will need to make this work from a transcluded(?) tiddler. I can pass the current tiddler name as $1 but I would prefer it it could be equal to the "current displayed tiddler".

Anyone else ?

Regards
Tony

Eric Shulman

unread,
Jul 6, 2012, 10:54:02 PM7/6/12
to TiddlyWiki


On Jul 6, 6:17 pm, TonyM <anthony.mus...@gmail.com> wrote:
> As I am automating this I will need to make this work from a transcluded(?)
> tiddler. I can pass the current tiddler name as $1 but I would prefer it it
> could be equal to the "current displayed tiddler".

The following code fetches the store object for the "current displayed
tiddler"

var here=story.findContainingTiddler(place); // get tiddler DOM
element
var title=here.getAttribute('tiddler'); // get title text
var tiddler=store.getTiddler(title); // get tiddler store object

If you like, you can write this all in one step:
var
tiddler=store.getTiddler(story.findContainingTiddler(place).getAttribute('tiddler'));


-e

PMario

unread,
Jul 7, 2012, 5:24:05 AM7/7/12
to TiddlyWiki
Hi Tony,
FND created a tagsplorer [1] macro, which may be interesting for you.
I did use it to organize my bookmarks.

-m

[1] http://svn.tiddlywiki.org/Trunk/contributors/FND/plugins/TagsplorerMacro.js
[2] http://pmbm.tiddlyspace.com/

TonyM

unread,
Jul 7, 2012, 10:54:09 PM7/7/12
to tiddl...@googlegroups.com
Tanks -m,

I do use Tagsplorer explorer and it is very useful, however in this case I want to use the current tiddlers tags #1 (Themselves Tiddlers with their own tags #2) - filter #1 based on #2 and return them in a form where I can use the results for multiple functions.

Are you suggesting I use the code from Tagsplorer ?

A Specific case example.
Of all the tags on the current tiddler a number of them indicate they are related to one or more projects. A Project tag/tiddler is indicated as such buy the a Project tag/tiddler having the tag "project". I want a facility to return all tags on the current tiddler that represent a project. Then I can choose how I will use this subset of tags.

So for the current tiddler I want to scan all its tags and determine which tags represent projects. In One case I want to display a horizontal line of "Projects" associated with this tiddler (Not showing other tags such as status/priority etc...) I would like each project to have a link to the project to open it and a checkbox to toggle if the current tiddler is tagged with the project, so I can quickly remove it.

The General case
This facility will see a gap I perceive in tiddlywiki fixed, where the tagging facility is very powerful yet once a tiddler is tagged you loose information about the tags because there is no attributes on the tags. This facility will allow me to lookup the attribute of a given tag - eg; it is a status tag, or project tag thus allow me to selectively handle tags on the current tiddler by this attribute.

Regards
Tony

twgrp

unread,
Jul 8, 2012, 9:00:54 AM7/8/12
to TiddlyWiki
I'm reminded of one of the problems I've encountered many times, so
just maybe you find value in this or perhaps it is the very same
question:

After much headache I eventually boiled down the question to this
phrase:

"List all tiddlers tagged with names of tiddlers that, in turn, are
tagged with a specific tag".

A practical example could be to "list all pupils that are tagged with
classnames". Each class is tagged with 'class' and the number of
classes are arbitrary so you can't hard code them into the 'where
clause'.

My listalizer of choce is fET but this does unfortunately not seem
possible there, at least not in a standard manner. If this is your
question, I'll provide the answers from the kind people here and
discoveries I made. (How you prefer to present the resulting list, "in
a line" or so, is another matter).

<:-)
> >http://svn.tiddlywiki.org/Trunk/contributors/FND/plugins/TagsplorerMa...
> > [2]http://pmbm.tiddlyspace.com/

PMario

unread,
Jul 8, 2012, 1:46:25 PM7/8/12
to TiddlyWiki
On 8 Jul., 04:54, TonyM <anthony.mus...@gmail.com> wrote:
> Are you suggesting I use the code from Tagsplorer ?
yup,
I thought you could borrow stuff there :)

But reading your descriptons, I think tobi beers stuff is where you
could borrow too :)

http://tbgtd.tiddlyspot.com
At a tiddlers toolbar see: x-tab▾ x-plore▾ x-tag▾

http://tagsearch.tiddlyspot.com/
tagSearch is similar to x-tag

-m

Tobias Beer

unread,
Jul 8, 2012, 5:57:52 PM7/8/12
to tiddl...@googlegroups.com
Hi twgrp,

What you want sounds like something that is useful in combination with HideWhenPlugin. So, if you have a student, you might want some "section" in your tiddler that shows the "classes" to which the student is tagging, but nothing else. But then, you might also want to remove those classes from the general tagging list. But I guess in your case you don't really want a tagging box at all... but only your dedicated "typed" tagging information.

It could be something like "grouped tags"... where you could define groups and give the groups a kind of template on how to display them, e.g. "students' classes"... you could also have a group "students", which would likely be displayed at the "class" itself, so you might want to also list all tiddlers tagging to a class that are themselves tagged "student". So the concept applies both ways to tags and tagging. In other words, tags need a qualifier... something that I have thought to be important for quite some time actually.

Today you would tag Mike as "student" and "biology101". However, what you really want is "student" and "class:biology101" ...something that qualifies the tag "biology101" as being a "class". You might find that out somehow as "biology101" would surely be tagged "class"... but it could also be tagged "winter2012" ...so you want to see some kind of "deferred" tags that are generally most important for tiddlers tagged "student", in other words "class"... and you probalby want to see those grouped.

So, your preferred tags or tagging box would perhaps look like this...

[[Some Student]]
Tags:
![[Classes|class]]
*[[Class X]]
*[[Class Y]]
![[Sports|sports]]
*[[Volleyball]]
!Other
[[SomeOtherTag]]

And likewise for [[Some Class]]:
Tagging:
[[Students|student]]:
*[[Mike Myers]]
*[[Jon Doe]]
*[[Alexa Alexandrovich]]
![[Books]]
*[[Biology Explained 101]]
*[[Bees and Trees]]
!Other
*[[Some other tiddler tagging to this class]]

Or perhaps instead of headings and lists as tables...
|[[Students|student]] |[[Mike Myers]] |
|~|[[Jon Doe]] |
|~|[[Alexa Alexandrovich]]|

etc...

As Mario suggested, one way could be to set up x-tab from tbGTD to display for each student a matrix of classes per weekday or grades per class or for each class a matrix of students per semester, etc...

Tobias.

TonyM

unread,
Jul 9, 2012, 8:42:56 AM7/9/12
to tiddl...@googlegroups.com
This does seem to cause a brain meltdown. The tags of the current tiddlers tags, according to their tags

All of you seem to be on the same track, Here is my example - which I have almost finished.

I Have a tiddler Called "Test - tags so tagged"
It has content - Including Eric's script
!Project(s)

<script>
var out=[];
for (var i=0; i<tiddler.tags.length; i++) {var tid=store.getTiddler(tiddler.tags[i]);
   if (tid && tid.isTagged("#")) out.push("[["+tiddler.tags[i]+"]]");
}
return out.join(", ");
</script>

Now this tiddler is tagged
=WIP =urgent :personal .projectTask [[Personal Process Improvement]]

The Above script in the above tiddler
displays "Personal Process Improvement" Because this tiddler is tagged with ""Personal Process Improvement"" and it is a project tiddler. Because all Project tiddlers are tagged with "#",

The script has evaluated all the tiddlers current tags, and tested them to see if they are tagged with "#" and listed the ones that are.

If I use "=" instead of "#" it would list the "status" tags because the tiddlers named =WIP =urgent are them selves tagged with "="

The Script does almost everything I want except I must insert it in every tiddler I want this to happen in. Unfortunately if I transclude the script from "anotherTiddler" it will return the result against the tags of the "anotherTiddler" not the transcluding one.

In my viewtemplate I would like to do something like this
<span macro="showWhenTagged .projectTask">
<div class='viewer' macro='tiddler anotherTiddler'></div>
</span>

Or
<span macro="showWhenTagged .projectTask">
[[ anotherTiddler]]
</span>

Or in another tiddler
<<tiddler anotherTiddler>>

I will post the applications once I have it.

Regards
Tony

Eric Shulman

unread,
Jul 9, 2012, 8:49:21 AM7/9/12
to TiddlyWiki
> The Script does almost everything I want except I must insert it in every
> tiddler I want this to happen in. Unfortunately if I transclude the script
> from "anotherTiddler" it will return the result against the tags of the
> "anotherTiddler" not the transcluding one.

See my prior response, where I explained how to get the current
"containing tiddler", rather than the transclusion tiddler:

http://groups.google.com/group/tiddlywiki/msg/21473ace780529e7

-e

TonyM

unread,
Jul 9, 2012, 9:34:56 PM7/9/12
to tiddl...@googlegroups.com
Thanks Eris,

I just don't have the knowledge to update your inline script

<script>
var out=[];
for (var i=0; i<tiddler.tags.length; i++) {
   var tid=store.getTiddler(tiddler.
tags[i]);
   if (tid && tid.isTagged("project")
      out.push("[["+tiddler.tags[i]+"]]");
}
return out.join(" ");
</script>

to include
tiddler=store.getTiddler(story.findContainingTiddler(place).getAttribute('tiddler'));
Such that I can transclude the above script.

So I am stumped.

I will eventually work it out but it is the old story I don't know what I don't know, so the only answer is to know everything about java script.

Regards
Tony

whatever

unread,
Jul 10, 2012, 6:01:54 AM7/10/12
to TiddlyWiki
Hi, Tony.

Try adding it at the beginning. I had a similar problem and I inserted
that line before the first reference to "tiddler" and it worked.

w

TonyM

unread,
Jul 10, 2012, 8:20:56 AM7/10/12
to tiddl...@googlegroups.com
Thanks Eric and whatever,

My mistake was trying to make sense of it, and thus thinking it was more complicated.

Now It Works and I will develop it further an re-post What I am doing with it.

Thanks

TonyM

unread,
Jul 17, 2012, 11:35:03 PM7/17/12
to tiddl...@googlegroups.com
Thanks Everyone for your help one this.

As Promised a quick statement on what this script has allowed me to do so that people who are looking for it may find it in the future.

The Script basically permits me to do something similar to the for each Tiddler but for each tag (on the current tiddler). Because you can create a tiddler "Tag tiddler", For each tag you use in your tiddlywiki, you can also tag the "Tag tiddler" as well. This is what I conciser an attribute of that tag.

Using the script in this thread you can then act on the current tiddlers tags selectively according to another tag. Examples would include;

From all the current tags list only those that represent a status tag
From all the current tags list only those that represent a Project Tag

This permits a tiddlywiki with a lot of tags to basically assign a type of attribute to each tag and you can treat them differently as the need arises.  Rather than have the user of the tiddlywiki interpret a complex set of tags, in a single tag line, you can extract the ones that are meaning full.

One example is all my ProjectTasks display a list of projects they belong to (usually only the one they are assigned to) just under the tiddler title. I do not need to scroll down and scan the tags with my eyes and determine which represent projects. To do this all my project tags - have tiddlers tagged "project". The script lists tags on the current tiddler that are also tagged "project". That is the tags with the attribute Project.

Currently I have only used the script to list the relevant tags, filtered by a particular tag and/or provide a checkbox toggle tag option for each tag to remove them.

Happy designing.

Futures ?
I would like to develop a series of tools to use and manipulate tags using this method. Examples include;
For all tags on this tiddler - Open their matching tiddler if tagged "attribute tag"
For all tags on this tiddler - Transclude them into the current tiddler if tagged "attribute tag"
For all tags on this tiddler - Provide tag/untag options if tagged "attribute tag"
Provide tag/untag options if tagged "attribute tag" but not already tagging this tiddler
Provide logical operations on tags if this tag then provide option to untage these other tags

And more

Regards
Tony
Reply all
Reply to author
Forward
0 new messages