[pmwiki-users] automatic link creation

adam overton a at plus1plus1plus.org
Wed Aug 26 14:10:41 CDT 2009


thanks everyone for the great suggestions!
i'll take a look and see which method will work best for me
thanks!
adam


On 26 Aug 2009, at 7:47 AM, Patrick R. Michaud wrote:

> On Wed, Aug 26, 2009 at 02:51:02AM +0200, Melodye Bowers wrote:
>> $foo = array('John' => 'http://www.abc.com', 'Sally' => 'http:// 
>> www.def.com');
>> foreach ($foo as $name => $site) {
>>    Markup('/\b'.$name.'\b/', '%newwin%'.$site.'%%', ...);
>> }
>>
>> Does that work?
>
> It "works", but only for very small numbers of names.  After adding
> 100 or so such rules the speed of markup processing will degrade
> noticeably.
>
> Better would be to combine all of the names into a single markup rule
> (code below is untested, for illustration only):
>
>     $foo = array('John' => 'http://www.abc.com',
>                  'Sally' => 'http://www.def.com');
>
>     Markup('names', 'inline',
>       '/\b(' . join('|', array_keys($foo)) . ')\b/e',
>       "'[['.\$foo[$1].'|'.Keep('$1').']]'");
>
> It's also possible that one could make use of the $IMap array
> for this in config.php (also untested):
>
>     $IMap['John'] = 'http://www.abc.com/';
>     $IMap['Sally'] = 'http://www.def.com/';
>
> Pm

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20090826/bb14161d/attachment.html 


More information about the pmwiki-users mailing list