HotWords

<< | Cookbook-V1 | >>

Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.


Goal

Allows the admin to make some words in WikiPages to appear as a link.

Solution

Attach:hotwords.php - PHP code

Discussion

Make a $HotWords map before including this file in local.php, e.g. put the following in local.php:

$HotWords = array (
"/PMWIKI/" => "<a href='http://www.pmichaud.com/pmwiki'>PmWiki</a>",
"/PMICHAUD/" => "<a href='http://www.pmichaud.com/'>Patrick Michaud</a>"
);
include_once( "local/hotwords.php" );

The wiki engine will now replace occurences of the 'hotwords' "PMWIKI" or "PMICHAUD" with the HTML we assigned to them in the $HotWords array. Feel free to add as many hotwords as you like. Note that hotwords are replaced at the end, so you can not process the results again as wikiwords or the alike. HotWords become very helpful if you have to include a link to a friend, or something similar, over and over again while editing your wiki. Now you can make it a lot easier by adding these as a HotWord to the $HotWords array, and using them a lot easier to include in your wiki pages.

Installation

Place the Attach:hotwords.php file in your local/ directory. Put includeonce(local/hotwords.php); in your local.php file, as indicated in the discussion section.

Discussion

This is probably the most lame extension for pmwiki ever, as it is the simplest way of adding new regular expressions to the way pmwiki internally works. However, it is a lot easier to be able to add new regular expressions to the formatting by providing an easy understandable way for new users. I would recommend this way of adding new and easy regular expressions as this implementation does not really show the inner working of pmwiki, but merely provides an abstract implementation of the way new expressions can be added to pmwiki. The user doesn't have to touch the $InlineReplacements variable, as it is taken care of by the (small) script. If the way $InlinReplacements is changing over time, and the HotWords functionality changes along with this, the user of pmwiki and HotWords doesn't have to change anything in order to have its local.php still working under this new engine. (This is standard practice in object orientation)

zet: Nice idea, but it would be more usefull if you were able to manage the hotwordlist in the wiki itself. Maybe it could be done by creating a page like Main.HotWords which is read by your script and where there are words defined like links: [[thehotword the text it replaces]]. In that case no new syntax would be needed. Your script would only have to read that wikifile and add it to the regexs. 30. August 2003, 10:00AM GMT+1

The hotwords.php file apparantly is not (no longer?) available from this page. Some users on our site were interested in this add-on, a pointer to where to get it would be appreciated. -- Arne

Contributors

  • Anthony Liekens

pmwiki-2.3.32 -- Last modified by {{Arne}}?

from IP: 85.171.160.186 ip should be disabled by default for security reasons