[pmwiki-users] Getting an URL from a cookbook recipe

christian.ridderstrom at gmail.com christian.ridderstrom at gmail.com
Wed Jan 25 15:46:07 CST 2006


On Wed, 25 Jan 2006, Patrick R. Michaud wrote:

> Oh!  You're wanting to use PmWiki markup to obtain urls rather than
> require the author to explicitly name the url.
> 
> The MakeLink function already allows this via its $fmt parameter...
> just do:
> 
>     $url = MakeLink($pagename, $target, '', '', '$LinkUrl');
> 
> I'm including a fuller description of the MakeLink function below.

I added the fuller description to this page:

	http://pmwiki.org/wiki/PmWiki/Functions#MakeLink

I do have some questions though... especially since I think I'll be using
MakeLink() shortly. So I might as well document it now... it seems this
will expand to need its own page though. I'll place it on:

	http://pmwiki.org/wiki/PmWiki/MakeLink

To start with, what does MakeLink()  return? Is it the HTML code of the
link pointing to $target?

> The general form of MakeLink is
>     MakeLink($pagename, $target, $txt, $suffix, $fmt)
> where
>     $pagename is the source page

I guess 'source page' would normally be the current page, and more 
generally the it defines the context for the link?

>     $target is where the link should go

What kind of things can $target be? Must it be a string with a URI?

>     $txt is the value to use for '$LinkText' in the output 
>     $suffix is any suffix string to be added to $txt
>     $fmt is a format string to use
> 
> If $txt is NULL or not specified, then it is automatically computed
> from $target.

Ok... I think I need some examples ;-)

> If $fmt is NULL or not specified, then MakeLink uses the default format
> as specified by the type of link.  For page links this means the
> $LinkPageExistsFmt and $LinkPageCreateFmt variables, for intermap-style
> links it comes from either the $IMapLinkFmt array or from $UrlLinkFmt.

How does MakeLink() know the type of the link? Is $target matched to 
various regexps?

> Inside of the formatting strings, $LinkUrl is replaced by the resolved
> url for the link, $LinkText is replaced with the appropriate text, and
> $LinkAlt is replaced by any "title" (alternate text) information
> associated with the link.

/Christian

-- 
Christian Ridderström, +46-8-768 39 44               http://www.md.kth.se/~chr






More information about the pmwiki-users mailing list