[pmwiki-users] Custom Markup for Rollover
John Rankin
john.rankin at affinity.co.nz
Mon Jul 17 17:39:31 CDT 2006
On Monday, 17 July 2006 10:39 PM, Paul Johnston <paul at pjnetsolutions.com> wrote:
>Still would like help with this, if only to figure out how to create
>Custom Markup correctly...
>
<snip>
>Ok - simplifying the question:
>
>I want to be able to add a Markup definition into my config.php that
>allows me to put something like this:
>
>(:rollover link img1|img2"alt":)
>
>(link could be a wiki link) and out comes something like this:
>
><a href="<linkurl>"
> onMouseOut="MM_swapImgRestore()"
> onMouseOver="MM_swapImage('ImageId','','img2',1)">
> <img src="img1"
> name="ImageId"
> alt="alt text">
></a>
>
>Let's get away from the CSS idea because I'm sure others would want to
>do the same as I'm trying to do here (and it's a thread about creating
>custom markup for a rollover).
>
><snip>
This is not trivial, but it can, I think, be done with a bit of care.
Try something like this:
In the following, if Attach: images are allowed, assume they have
already been uploaded, so the markup only has to deal with
references to attached images that already exist.
Markup('rollover','<links',
"/\(:rollover\s+([^\s$UrlExcludeChars]+)\s+([^$UrlExcludeChars]+$ImgExtPattern)\|([^$UrlExcludeChars]+$ImgExtPattern)\"([^\"]+)\"\s*:\)/e",
"Keep('<a href=\"'.MyMakeLink(\$pagename,'$1').'\"
onMouseOut=\"MM_swapImgRestore()\"
onMouseOver=\"MM_swapImage(\'ImageId\',\'\','.MyMakeLink(\$pagename,'$3').',1)\">
<img src=\"'.MyMakeLink(\$pagename,'$2').'\" name=\"ImageId\" alt=\"$4\">
</a>')");
The new function called MyMakeLink($pagename, $text) needs
to return a link of the form http://...
It has to handle the following cases:
$text is a url, an Attach: image, a pagename with or without a groupname.
If it's a url (starts with 'http://'), return $text.
If it's an Attach:, change 'Attach:' to the prefix for uploads.
If it's a pagename, add a group prefix if necessary, and return a page url.
I apologise in advance for any typographical errors in the
Markup call -- it's quite complex. Hope this gives you a
few pointers in the right direction.
--
JR
--
John Rankin
More information about the pmwiki-users
mailing list