[dokuwiki] Re: links in plugins

  • From: Chris Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sat, 02 Dec 2006 03:24:27 +0000

Martin Tschofen wrote:
I've implemented popup links inside a command plugin extension.

#ui?popup(wikiID=label|wikiID=label|wikiID=label)#
It's a popup that allows the user to select

I noticed that links created like this, don't end up showing up in the
backlinks.

What do I need to do so that DW recognizes links created in such a way
and ads the pages connect this way in the backlinks?

Hope this makes sense and thanks in advance...martin

iirc, backlinks are determined from the search index and the page metadata. The index quickly finds pages who's content includes the page name and the metadata confirms that the found pages have links to the current page. To add metadata to the page your plugin will need to handle the metadata renderer (respond to the $format="metadata" in the render() method) and write the metadata key, "relation references" for each link. e.g.

function render($format, &$renderer, data) {
 switch ($format) {
   case 'xhtml' :
     /* do your wiki page xhtml output, e.g $renderer->doc = "..."; */
     break;

   case 'metadata' :
/* set required metadata keys, e.g. $renderer->metadata[<primary key>][<secondary key>] = value; */
     break;

   default :
     /* do nothing for other (unsupported) formats */
 }
}

For more information you should:
- check out the metadata renderer, inc/parser/metadata.php, in particular the functions concerned with internal links.
- the backlink functions, mainly ft_backlinks() in inc/fulltext.php
- have a look at a plugin which writes metadata, some of the plugins in Esther's blog/discussion plugin family do that.

You may even find its sufficient to have your metadata handling call the metadata renderer's internallink() function for each link in your popup.

What you shouldn't do is use the p_set_metadata() function - its for metadata requirements outside of the current page rendering.

Cheers,

Chris

PS. If you find this useful, please take the time to add something to the plugin reference/tutorial pages at splitbrain.org. :)
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: