Summary: Add or remove a page from your watchlist trail with a single click
Version: 20180221
Prerequisites: PmWiki 2.2.17 or newer
Status: beta
Maintainer: Petko
Users: +1 (view / edit)
License: GPL3+


The recipe offers an easier way for authors to manage their watchlist trails.

WatchLists are used by wiki authors to monitor changes to a selected list of pages. The watchlist can be displayed in a profile page or can serve to send e-mail notifications to the author.

Watchlists are organized with WikiTrails, simple bulleted lists of links to the watched pages. This recipe enables easy addition or removal of a page to the watchlist trail of the author.


The recipe requires PmWiki version 2.2.17 or newer.

  • Copy addtowatchlist.phpΔ to your cookbook directory.
  • Add to local/config.php such a line:
    $PostConfig["$FarmD/cookbook/addtowatchlist.php"] = 100;
You can insert a "Watch"/"Unwatch" link into your page actions (View, Edit, History, Print...). Edit your wiki page Site.PageActions and add a line like this:
* %rel=nofollow% [[{*$FullName}?action={*$WatchlistAction} | {*$WatchlistText}]] %%


You can configure the watchlist page format, related to the Author profile page. In config.php you could add one of those lines:

$WatchlistTrailFmt = '{$FullName}-Watchlist'; # for Profiles.UserName-Watchlist
$WatchlistTrailFmt = 'Watchlists.{$Name}';    # for Watchlists.UserName

The page variables in the format are related to the user profile page. This format is not required, if not set, the user profile page will be used.

Watching multiple pages

With the default configuration the user adds to or removes from her watchlist a single page, the one currently visited. Since version 20180221, it is possible to add to and remove from your watchlist multiple pages at once, for example the "page", the "talk page" and the "users page" by following the "(un)watch" link on any of these. The following configuration needs to be added to config.php (adapt it for your needs):

$WatchMultiplePages = array('{$BaseName}', '{$BaseName}-Talk');
$BaseNamePatterns['/-(Talk)$/'] = '';

The above lines will automatically add to or remove from the watchlist the pages "Page" and "Page-Talk" (if you run a wiki similar to Wikipedia).

$WatchMultiplePages = array('{$BaseName}', '{$BaseName}-Talk', '{$BaseName}-Users');
$BaseNamePatterns['/-(Talk|Users)$/'] = '';

The above lines will automatically add to or remove from the watchlist the pages "Page", "Page-Talk" and "Page-Users" (if you run an installation similar to the Cookbook on

The cluster of pages will be added to the watchlist even if one or more of the pages do not exist.


If you add the special link in Site.PageActions, this link will appear on every page. If the page isn't in your watchlist trail, you will see the "Watch" link; if it is, you will see the "Unwatch" link. Clicking on this link will open your watchlist trail, with an added or removed link to the page.

Your watchlist trail will look like this:

It lists the pages you are watching (newly added pages appear on top); clicking on the "Unwatch" link will remove the page from the trail.

The recipe adds 3 new PageVariables and a conditional which can be used in wiki pages and in pagelists:

  • {*$WatchlistStatus} : "1" if the current page is watched, "0" otherwise.
  • {*$WatchlistAction} : should be used in the special link and is "unwatch" if the page is watched, "watch" otherwise.
  • {*$WatchlistText} : the link text, "Watch" or "Unwatch", but shows the translated text in international wikis.
  • {$WatchlistTrail} : the watchlist trail page of the current user.
  • (:if watching Group.Page:) the conditional; Group.Page is not required, if missing, the current page is assumed.


For international wikis, you can translate the following strings, eg. in your French XLPage:

 'Watch'   => 'Suivre',
 'Unwatch' => 'Ne plus suivre',
 'Watchlist not saved' => "La liste de suivi n'a pas été enregistrée."


  • An author name is required for the script to know where is your watchlist trail page, and you need edit permissions for that page. If you aren't logged in and follow a "Watch" link, you may see two prompts, one for your name, the other for the password (depending on your wiki configuration).

Change log / Release notes

  • 20180221 : add $WatchMultiplePages.
  • 20170810 : add change summaries, this makes the recipe work with RequireSummary. In case a watchlist cannot be saved for some reason, any messages for the reason ($MessagesFmt) will be displayed. Add 'Watchlist not saved' error message to translate.
  • 20110325 : fixed typo in 2 variable names, reported by RandyB.
  • 20110322abc : default the recipe actions to lowercase "action=(un)watch"; added $WatchlistTrailFmt; removed global $AuthorListPage, minor refactoring of the code; added {$WatchlistTrail}.
  • 20110321a : fixed problem with lost history, reported by RandyB.
  • 20110321 : first release, ready to be tested.

See also

  • WatchLists explains how to configure the pagelist for a more convenient monitoring of the changes.
  • TrackChanges Ways to more easily detect and verify all recent edits
  • Notify How to receive email messages whenever pages are changed on the whole wiki site, individual groups or selected watchlists of pages
  • WikiTrails Trails from lists items from a single page


  • Recipe written and maintained by Petko (5ko [snail] 5ko [period] fr).
  • If this recipe helps you or saves you time, you can help support its continued development by .


See discussion at AddToWatchlist-Talk

User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.