Aliases and ^childLinks^


(Mark Anderson) #1

I noticed that this aTbRef page (since fixed) had no content. The page is exported from an alias. Its original, in the ‘Formatting’ section of the doc, has this body as its entire $Text:

^childLinks^

IOW, only a single export command, to produce this page. I assumed that as an alias shares its original’s links that the export code would create the same. Also, I recall agent queries can test descendants of the aliases original even though the alias has none itself. Anyway, the empty body text in the (now-fixed) page showed me that ^childLinks^ is evaluated in the current (alias) context and as the alias has no children, no links are generated.

Bother. ^childLinks^ doesn’t allow an offset reference, e.g. ^childLinks(original)^ (this won’t work), so more cumbersome work-around is needed. Thus, the original note in the TBX now has this code. There it is all in one line but broken out here to show the structure:

^if($IsAlias)^
^include("Support for other app-specific formats","body_text_only")^
^else^
^childLinks^
^endIf^

The template ‘body_text_only’ just contains the code ^text^. Now the original works as before. The alias, now fetches the export-evaluated $Text of the original - i.e. an HTML link list of the original’s children and uses that as the aliases own body copy for the exported page.

Note, we can’t use ^value($Text(original))^ for the alias as that would be returned verbatim as “^childLinks^”, i.e. not export-evaluated into the HTML list.

I hope that saves others a bit of head-scratching if they too encounter this scenario.


(eastgate) #2

I assumed that as an alias shares its original’s links

Long ago, this was true. (And fair Margaret remembers that for me. – John Prine)

But in Tinderbox today, aliases have their own links.


(Mark Anderson) #3

No problem, the code as cited works fine to work around the issue. I’m aware of the path the the alias/links status quo, not least having been one of those arguing for it.

I only wondered re child links because they are hierarchical and not actual links. Aliases can’t have children, but their originals can. Anyway, no worries. I mainly posted here as its’s an arcane issue that some might meet and for which a perfectly simple solution is given above.