I think I got it:
return wikify('[['+store.getTiddler(story.findContainingTiddler
(place).getAttribute("tiddler")).getLinks().sort().join(']]\n[[')
+']]',place);Now how would I make it take into account the chkDisableNonExistingWikiLinks=true? Perhaps DisableWikiLinksPlugin should remove such links as well, not excluded links only. -- R On Apr 21, 6:53 pm, RA <[email protected]> wrote: > Eric, > > I realised I don't need the whole "recursive" list or tree. How can I > display a list of links from the current tiddler only (internal and > external), i.e. the first level of the tree? > > Thanks. > > On Apr 20, 6:49 pm, Eric Shulman <[email protected]> wrote: > > > > Works well except the "making it visible" part is not working for me. > > > The span remains hidden unless I remove the style from ViewTemplate. > > > hmm... not sure about that one. > > > > Also, wouldn't it be more economical to check tree.length instead of > > > calling getList just to get the number? > > > config.macros.relatedTiddlers.getList() > > returns an array of related tiddler titles > > config.macros.relatedTiddlers.getTree() > > returns a single text string containing the entire wiki-formatted > > tree of related tiddlers > > > Thus, to check the # of items returned, you can write either: > > config.macros.relatedTiddlers.getList(...).length; > > OR > > config.macros.relatedTiddlers.getTree(...).split('\n').length > > > The first approach counts the items directly in the array... the > > second approach splits the tree output into an array of separate lines > > and then count the number of items that results. However, even though > > its likely that the second approach would be more efficient for most > > cases, I used both functions solely in order to demonstrate how they > > might be applied. > > > -e > > > > Thanks Eric. > > > > -- R > > > > On Apr 20, 7:27 am, Eric Shulman <[email protected]> wrote: > > > > > > I'd like to use RelatedTiddlersPlugin in a manner similar to > > > > > SectionLinksPlugin. > > > > > You mean like the <<sectionTOC>> macro (which automatically generates > > > > a tree of links to sections *within* the current tiddler)... but > > > > showing a tree of TiddlyLinks to related tiddlers instead of sections? > > > > > > A primer would be appreciated on how to achieve the following > > > > > functionality (I suspect most of it can be had using the provided > > > > > API?) > > > > > The Usage section of the plugin documentation says: > > > > ----------------------------- > > > > The plugin also defines two functions that can be called externally > > > > (from other plugins or scripts) to generate and retrieve either a list > > > > of links or a formatted "tree view": > > > > var list=config.macros.relatedTiddlers.getList > > > > (start,exclude,callback); > > > > var tree=config.macros.relatedTiddlers.getTree > > > > (start,exclude,callback); > > > > These functions accept parameters to specify the starting tiddler, and > > > > a list of tiddlers to exclude, as well as an optional callback > > > > function that takes any specified tiddler as input and returns a > > > > custom-defined array of links related to that tiddler: > > > > var list=callback(tiddler); > > > > Use of the callback function enables you to generate an alternative > > > > list/tree, based on application-specific data (such tiddler references > > > > contained in tags or custom fields), rather than using the default > > > > "links" list. > > > > ----------------------------- > > > > > In addition, the Examples section of the plugin documentation, shows > > > > some sample inline scripting to invoke the plugin-defined function. > > > > With a few changes, this script will do exactly what you want: > > > > ----------------------------- > > > > <script> > > > > var here=story.findContainingTiddler(place); > > > > var target=jQuery('#'+here.id+' .relatedTiddlers')[0]; > > > > var start=here.getAttribute('tiddler'); > > > > var > > > > exclude=config.options.txtRelatedTiddlersExclude.readBracketedList > > > > (); > > > > var count=config.macros.relatedTiddlers.getList > > > > (start,exclude).length; > > > > if (count>1) { > > > > var > > > > tree=config.macros.relatedTiddlers.getTree(start,exclude); > > > > if (target) target.style.display='inline'; > > > > wikify(tree,target||place); > > > > } > > > > </script> > > > > ----------------------------- > > > > > This will generate the desired tree output, starting from the current > > > > tiddler.title and then uses a jQuery() call to locate and render the > > > > desired 'target' element (by matching the .relatedTiddlers classname) > > > > within the currently rendered tiddler. Note: if no such target > > > > element is found, the output is written directly into the current > > > > 'place' (i.e., the location where the script itself is being > > > > rendered). > > > > > To invoke this script from within your ViewTemplate (so the tree is > > > > automatically rendered for each tiddler), first put it into a separate > > > > tiddler (e.g., [[ShowRelatedTiddlers]]), and then write the following > > > > in the template: > > > > ----------------------------- > > > > <span class='relatedTiddlers small' style='display:none' > > > > macro='tiddler ShowRelatedTiddlers'> > > > > <b>Related:</b><br> > > > > </span> > > > > ----------------------------- > > > > This both creates the target element *and* invokes the script that > > > > renders the tree into it. > > > > > enjoy, > > > > -e > > > > Eric Shulman > > > > TiddlyTools / ELS Design Studios --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/TiddlyWiki?hl=en -~----------~----~----~----~------~----~------~--~---

