Tinderbox Forum

Links to notes names within a set or list

Making a link of type ‘who’ from a person to a meeting fills ups the set of $Attendees using the code
$Attendees=links.inbound.“who”.$Name;

Similarly making a link of type ‘mtg’ from a mtg to a project fills up the $MySet of the Project
$MySet=links.inbound.“mtg”.$Name;

This method of passing attribute values using links code is very useful ( Thanks Michael Becker for the idea…)

I’m looking for a way to output links to the notes like - “Links to all meetings for My Big Project “ ie those listed in the projects MySet and likewise “Links to all attendees for mtg 1” ie those listed in $Attendees
forum_request_links.tbx (135.7 KB)

Grateful for any help - small sample tbx to illustrate request attached

1 Like

Done! Preview:

forum_request_links-ed.tbx 2022-04-24 14-48-30

Done via template code:

<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">
	<title>^title^</title>
</head>
<body>
<h1>^title^</h1>
Meetings related to ^title^:
^action(
$MyString=;
$MyString+="<ul>\n";
$MySet.each(anItem){
   var:string vPath = $Path(anItem);
   $MyString+='<li><a href="'+$HTMLExportPath(vPath)+'">'+anItem+"</a></li>\n";
}
$MyString+="</ul>\n";
)^^value($MyString)^^action($MyString=;)^

</body>
</html>

Amended TBX with the above: forum_request_links-ed.tbx (139.3 KB)

Notes:

  • export templates can’t access variables in ^action()^ calls, so it is necessary to an attribute to ‘bridge’ into the export context. Therefore I use the note’s $MyString, taking care to reset it after so we don’t store loads of cruft as a result of export.
  • I tried using ^linkTo(anItem)^ in the .each() loop but again we hit an issue of variable values not transferring. Basically, export code doesn’t presume doing this sort of offset HTML code list construction. But, you could use the same technique with ^include(this, "template_name")^ to make it easier to drop the list in with other exported per-note data (note: that wasn’t specified in the opening problem)

OK, I implemented the listing via an ^include()^: forum_request_links-ed2.tbx (145.6 KB)

Now, ‘big project’ uses the original solution, and ‘little project’ uses the new solution. Looks at the templates for each.

A further step might be to parameterise what list we use, e.g. $SomeOtherList rather than $MySet, would be to use a function to generate the list.

And here’s a third version, now using a function—so I’ve added a third project and some meetings.

Now, each project gets to the same result, an HTML list of links to meetings but via a slightly different and more refined method. Use any one you like. There is no ‘right’ version.

Here the updated TBX file: forum_request_links-ed3.tbx (179.1 KB)

I hope that helps :slight_smile:

Wow! Thanks Mark - appreciated and some good learning points too

1 Like

Hi Mark, just looking at this - I presume the 5th line - iList.each(anItem) - is meant to use the declared variable vList?

function fMakeLinkList(iList){

	var:list vList = iList;
	var:string vResult=;

   vResult+="<ul>\n";
   iList.each(anItem){
      var:string vPath = $Path(anItem);
      vResult+='<li><a href="'+$HTMLExportPath(vPath)+'">'+anItem+"</a></li>\n";
   };
   vResult+="</ul>\n";

   return vResult;

};

Sorry, yes. As it happens they are the same. A corrected TBX is here: forum_request_links-ed3.tbx (170.9 KB)

The correct in in one line in the function fMakeLinkList. It is:

vList.each(anItem){

Why set a variable to input ‘iList’? All input currently arrive as string type values, regardless of their source. By declaring a typed variable (var:list) we ensure we have something Tinderbox will treat as a list and allow us to iterate its values.

2 Likes

Thanks once again Mark

When in preview tab looking at the output - clicking on a link such as ‘mtg 1’ flicks straight away to the preview of note ‘mtg 1’ ( as expected )

However in another file where I have successfully used your function & template to list the children of a note via the notes rule - $MySet=collect(children,$Name) preview appears to stays stuck on the same note. However when I choose the text tab it’s clear that there has been a successful link to the new note and then I have to choose preview to view it - not sure why the behaviour differs between two tbx files?

Preview is for previewing files before exporting [sic]. Of late some users have wanted to use (at least read) their documents only using preview mode. I’m not sure that is always possible and—at present—ought not to be a default assumption.

So, I don’t think the issue is the ‘code’ of the template so much as the mode of use. I wonder if it is because the target note is set to not export (recall it’s an export preview) or because the target is not unique. Are there two notes of the same name (or a note and an alias of it in the same container?

All sorted thanks- There was a mix of both the ssues you mentioned. Half with templates not set and a couple of identical names in same container - However I noted that my Notes inspector (command-1) was veeery slooow to update itself when changing between notes and agents were taking forever… Closed down all apps and rebooted and all issues solved - many thanks

Slowdown can point to busy-ness at two different levels. For years I’ve kept the Mac’s Activity Monitor open and watched memory levels, especially being one of those who only tends to re-boot/shutdown for OS upgrades. Now I use iStats Menu to watch for CPU load (normally transitory, e.g. app stuck in a busy loop) or memory load (something needs a close/re-open. Sadly, in current macOS eventually the OS’ ‘WindowServer’ process will consume loads of RAM and can only be re-started with a full reboot (boo, Apple).

At app level, the Agent & Rules Inspector is your friend. It is a bit gnomic, but it is a glimpse behind the curtain of the work you’ve—perhaps unintentionally—inflicted on your doc. For instance, if you’ve lots of agents, whose contents rarely/never change or need to run their actions, set them to ‘off’ ($AgentPriority, see the Query Inspector). Inactive agents retain their aliases—but don’t run actions on them—so can often be a good optimisation. Big rules (or edicts) can also be a roadblock. We write them, fix the issue then leave them running. Set via a prototype they can end up as unneeded code running on 000s of notes, all sucking ‘power’ from the app. Note: $RuleDisabled (and similar attributes for edicts, Display Expressions and Hover Expressions) are not inherited. Turning the rule off in a prototype does not affect inheriting notes.

HTH

†. Whole extra topic, but if this is an issue and you need to explore how to toggle prototype-inherited Display Expression, Hover Expression , etc., on/off let’s start a new thread.