Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Using ^inboundLinks()^ (Read 3235 times)
Charlyn Lee
Full Member
*
Offline



Posts: 35

Using ^inboundLinks()^
Dec 30th, 2010, 9:58pm
 
Referring to Nakakoji text export,
When using ^inboundLinks()^ I realised that the export text will look like:
<a href="">Some Title</a>
rather than:
Some Title

I'm aware that after exporting, I could use a find and replace to remove the specific text. However I was wondering if it could be removed (or edited) natively in Tinderbox (perhaps some attribute?) on export, which could save me the find and replace process?

Thanks!
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Using ^inboundLinks()^
Reply #1 - Dec 31st, 2010, 4:20am
 
Nakakogi is for plain text - so, in general, don't use HTML-link-creating export codes in your plain text export templates. for your current task we need to take a different route and use links() to collect a lost of the $Name of linking-in notes then format() to format those to a suitable on-screen layout
Back to top
 
« Last Edit: Dec 31st, 2010, 7:29am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Using ^inboundLinks()^
Reply #2 - Dec 31st, 2010, 8:35am
 
The following is a bit generic (as I can't see your exact context). I'll give a longer an shorter version. I intend you use the latter but the former should help you see how the shorter version works. so, the basic concept is:
  • We add a set** user attribute $MySet - to hold the output of a list() call
  • We add a string attribute $MyString - to hold the result of formatting $MyList
  • We then use the ^value($MyString)^ in place of ^inboundLinks^


**Side note. In simple terms a 'set' in TB is a de-duped 'list', though in most other aspects the two data types are the same. Here we use a Set as we know links() always returns a set. The latter is so that if a note links in using more than one link type, it only gets listed once. End side note!

So. the long version. Our $Rule for notes otherwise using ^inboundLinks^:

$MySet = links().inbound.$Name; $MyString = "* "+format($MySet,"\n* ")

In the export template we change ^inboundLinks^ to ^value($MyString)^

To explain the Rule. We set out set to collect, for the this note, for all inbound links, of any link type, the $Name of the linked note. We know have a set (list) of note names representing the inbound links but we want a little formatting. Lets put an asterisk and spacebefore each item with each item on a new line. As the fromatting string applies to the test added between each list item, we also add an asterisk+space before the output of format so the first item is correctly prefixed too. The "\n" bit is how we tell TB to output a new line.

The ^value^ command now reads and inserts a multi-line bit of text like:
* ant
* bee
* cow
* dog


Short version now. We can nest the links() call inside the format() call and the format call inside the ^value()^ call and do it all in one go so we don't need the extra attributes.  Instead of ^value($MyString)^, we use:

^value("* "+format((links().inbound..$Name),"\n* "))^

Note the extra "()"  - in red - around the nested links() as this tells format() to evaluate that code before doing the list formatting task.
Back to top
 
« Last Edit: Dec 31st, 2010, 9:23am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print