Recent Changes - Search:



This page describes an internal function in PmWiki's engine called LinkIMap(). The contents are not intended for those with a weak heart ;-) Admins (advanced)

Also see: PmWiki.Functions#LinkIMap, PmWiki.MakeLink


The function LinkIMap() handles links of the form scheme:path, which includes http:, https:, ftp: as well as the inter map links such as Cookbook:, PmWiki: etc.

The basic markup behind the eventual invocations of this function is as follows:

	[[ <target>"<title>" | <link-text> ]]
	[[ <link-text> -> <target>"<title>" ]]

The arguments to the function are as follows:

  • $pagename — a string with the name of the page context in which the link is created, this is typically simply the name of the current page. For example, $pagename could be "Group.SomePage".
  • $imap — a string denoting the scheme, i.e. the index into $LinkFunctions. For example, $imap could be "http:".
  • $path — a string with the part of the target after the scheme
  • $title — a string with the optional part after the target within quotes
  • $text — a string with the link text, from MakeLink()
  • $fmt — a string with the format string, from MakeLink()

The array $IMap is the primary array used by LinkIMap(). It says how to format a URL according to the given scheme. By default, this array is generally set as follows:

	$IMap['http:'] 	    = 'http:$1';
	$IMap['https:']     = 'https:$1';
	$IMap['ftp:']       = 'ftp:$1';
	$IMap['mailto:']    = 'mailto:$1';
        $IMap['Cookbook:']  = '$1';
        $IMap['PmWiki:']    = '$1';
	$IMap['Wikipedia:'] = '$1'; 

Note that the $1 in each case is used as a placeholder for the path component.

LinkIMap() then uses the value of $UrlLinkFmt to generate the link.

Then there is also the array $IMapLinkFmt that allows each scheme to have its own custom formatting default. The vanilla version of PmWiki doesn't use this array yet, although some cookbook recipes probably do.

Examples of custom formats to allow different styling via classes:

  • Links to http: standard url links:
    $IMapLinkFmt['http:'] =
      "<a class='httplink urllink' href='\$LinkUrl'>\$LinkText</a>";
  • Links to https: secure pages:
    $IMapLinkFmt['https:'] =
      "<a class='httpslink urllink' href='\$LinkUrl'>\$LinkText</a>";
  • Links to PmWiki: InterMap shortcut:
    $IMapLinkFmt['PmWiki:'] =
      "<a class='pmwikilink urllink' href='\$LinkUrl'>\$LinkText</a>"; 
  • Links to Cookbook: InterMap shortcut
    $IMapLinkFmt['Cookbook:'] =
      "<a class='cookbooklink urllink' href='\$LinkUrl'>\$LinkText</a>"; 

Category: PmWiki Internals

This page may have a more recent version on PmWiki:LinkIMap, and a talk page: PmWiki:LinkIMap-Talk?.

Edit - History - Print - Recent Changes - Search
Page last modified on September 25, 2013, at 01:14 AM