[pmwiki-users] Complex links with standard markup?

Peter Bowers pbowers at pobox.com
Tue Feb 28 08:41:00 CST 2012


On Tue, Feb 28, 2012 at 2:42 PM, Martin Kerz <mkerz at me.com> wrote:
> is it possible to create complex links using standard markup? I would love to have something like this:
>
> <a href="Group/Page">
> <h3>Link</h3>
> <p>This is a fine link</p>
> <p><b>that you should click</b></p>
> </a>
>
> If not, is there a recipe to provide that kind of functionality?

Something that specific is almost certainly not going to have a
ready-made recipe for it, but making your own custom markup for
something like this is very simple...

Markup('mylinks', 'inline', '/\(:mylinks(.*?):\)/ie',
'MyLinks(\$pagename, "$1")');

function MyLinks($pagename, $args)
{
	$opts = ParseArgs($args);
	$href = $opts[''][0];
	$link = $opts[''][1];
...for $finelink and $youshouldclick
	$rtn = "<a href=\"".$opts[''][0]."\"<h3>$link</h3><p>$finelink</p><p><b>$youshouldclick</b></p></a>";
	return Keep($rtn);
}

Put that in your config.php and then you can access it via markup like this:

(:mylink Group/Page Link "This is a fine link" "That you should click":)

The number of arguments is hardcoded to 4 in the way I've done it --
certainly there are ways you can improve on this (starting with
checking ot make sure there are exactly 4 arguments).  But it should
give you a starting direction.

-Peter



More information about the pmwiki-users mailing list