Link type during export as HTML

I have the following code in an export template which I use to export notes into plain text files:

Links To: ^value($LinksTo)^

This currently gives me the name of the note which is linked to the exported note, like so:

Links To: Using TBX for notes

What I would like to do is also export the link type. Such that the output might be something like:

Links To: Using TBX for notes (exception)

where “exception” is the “link type” for my link from the exported note to the note entitled “Using TBX for notes”.

Is this possible?

How are you populating $LinksTo? It appears to be a user attribute. Therefore the sensible thing to do would be to append the desired link type value to the $LinksTo attribute when you populate it.

The latter process depends on unpicking a number of assumptions:

  • What code/method sets $LinksTo.
  • Do such notes link to more than one other note.
  • How many link types are actively used.
  • What happens if a note links using more than one link type.

It is not possible (AFAICT) to use action code to get a list of the links types in use for a note’s outbound (or inbound link). You can filter linkedTo() and linkedFrom() results by a given link type but the latter is a manually entered parameter.

How did you envisage this method working, given the points above? With a bit more info perhaps we can figure something out.

Thank you for your questions, Mark.

I am making the links manually in Outline View. You are right, of course, that $LinksTo is a user attribute. (I also made a $LinksFrom attribute.)

I am not sure I understand your idea about appending the desired link type value to the $LinksTo attribute. That attribute is currently populated by using a Rule:

$LinksTo=links.outbound.“=agree|clarify|disagree|example|exception|note|note+|response|update”.$DisplayName;
$LinksFrom=links.inbound.“agree|clarify|disagree|example|exception|note|note+|response|update”.$DisplayName;

As you can see, I specify which Link Types can populate my user attributes. The exact number of types may change in time.

Notes may indeed link to more than one other note.

What I would like is use code in the template to present the type of link type somehow. So just as I can use code to output what the $Name of the link in my template, I would like it to be able to use code to output the Link Type. If the note used more than one other note, I would like each one to be outputted separately. Something like:

Links To: Using TBX for notes (exception), How to use this file (example), Reading methods (response).

1 Like

OK. Sadly I don’t think you can automate extraction of data in that way. I suggest you email support and make a feature request.

Will do, Mark, thank you.

I wonder if there is some other way to achieve the same end — to extract some data other than the name from a note that is linked to, and use it in a template through some code?

Just as one can get the value of, say, $Name(parent), is there some way to get the $Name(linked-to-note), or any other attribute?

See linkedFrom() and linkedTo(). In each case you can optionally give a string value of a link type. I’ve just tested and it appears that the option linktype value is a string literal and not an evaluated term (i.e. you can’t store the desired link type in $MyString) nor can the value be more than one discrete link type.

These two action functions do what they were originally designed for, and might, with some extension, perhaps help with your case - thus the suggestion of a feature request. For instance if the second input parameter were evaluated rather than literal.