Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

AddToWatchlist-Talk

Summary: Talk page for AddToWatchlist.
Maintainer: Petko
Users: +1 (View / Edit)

This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.

This is a wonderful recipe. It could be even better with a few more configuration options.

It appears the watchlist can be kept on a page other than the author's Profiles page (or that page with a suffix). For example, I seem to be able to use in config $AuthorListPage="MyPrivateGroup.$Author";. Is that safe to do?

Yes, from version 20110322 you can use $WatchlistTrailFmt = 'MyPrivateGroup.{$Name}';, documentation updated. --Petko March 22, 2011, at 04:23 AM

FYI, I think you made a typo in your script. In version 20110322c I have to specify "Watchist" not "Watchlist" to get it to work. RandyB March 25, 2011, at 01:13 PM

Thanks, corrected. --Petko March 25, 2011, at 01:29 PM

Is there a way to specify terminology other than "Watch" and "Unwatch" - for example "Star" and "UnStar" or "Remember" and "Forget"?

Yes, you can "set" the English "translations" like this:
XLSDV('en',array('Watch' => 'Star', 'Unwatch'=>'Forget')); --Petko March 21, 2011, at 02:40 PM

Is there a way to control where redirection goes after the post, for example, if I want the user to stay on the current page rather than go to the page where the list is stored?

Yes, you can add to the special link url &goto={*$FullName} like:
[[{*$FullName}?action={*$WatchlistAction}&goto={*$FullName} | {*$WatchlistText}]]
After some use I found that most often I prefer to see the watchlist, and if I want to stay on the current page, I'll middle-click the Watch link to open a new tab. --Petko March 21, 2011, at 02:40 PM

You can also redirect to a fixed page with &goto=Group.Page in the link or you can set a default redirect page with the variable $WatchlistRedirectFmt = "Group.Page"; in config.php. Petko March 22, 2011, at 04:44 AM

Is there a way to encode extra info in the target? For example, "&goto=Site.Watchlist?extrainfo=Preferences.{$Author}%23AddToWatchlist" won't work because the extrainfo would be dropped. - RandyB March 21, 2011, at 06:49 PM

How would you use this extra info? If I understand correctly, you want a single watchlist page for all users, which would construct pagelists based on the author name (brilliant idea)? In that case, I think it is better to use a page variable, either create one or use {$WatchlistTrail} added in version 20110322a. Petko March 22, 2011, at 04:44 AM

For example on my watchlist page I might have "[[{$?returnto}|Return to {$?returnto}]]" and the page might make use of "{$?MaxPagesToShow}". I use URL parameters for all sorts of things. RandyB March 22, 2011, at 06:00 AM

The "Return to Page" link can be done with something like (:pagelist trail={$WhachlistTrail} count=1 fmt=#my_return_fmt:). The max number could be set in a different way - preference, page variable for a different page, pagelist with request=1 parameter, etc.. In case you have to pass such and other things in the link url, you can write a custom $WatchRedirectFunction which can append these things to the url that this recipe returns. --Petko March 22, 2011, at 05:50 PM

You can probably anticipate my next question...

Can I use an image such as an uncolored star for Watch and colored star for UnWatch - thereby allowing the user to toggle the page on and off the list? ("Starred pages" are becoming common - for example in Google Docs.)

- RandyB March 21, 2011, at 12:43 PM

Great idea. You could do the same as with the English "translation", use the "★" star or ♡ ♥ hearts Unicode characters. You can use grey and gold colors if you like:
XLSDV('en',array('Watch' => '%gray%★%%', 'Unwatch'=>'%color=gold%★%%'));
There is a list with several special characters here [1] [2].

You could even set star icons, just use the url address like you would include a picture:

XLSDV('en',array(
  'Watch' => 'http://yoursite/pub/star-gray.png"Page not in your watchlist. Click to add it."',
  'Unwatch'=>'http://yoursite/pub/star-gold.png"Page in your watchlist. Click to remove it."'));

It is probably a good idea to add "tooltip titles" to the icons (see PmWiki:Images) so that your users know what the icons do. --Petko March 21, 2011, at 03:21 PM

Found a problem: "Watching" or "unwatching" a page eliminates the history for the target page where I keep my list. RandyB March 21, 2011, at 01:42 PM

Nice catch, thanks, fixed in 20110321a (just released). --Petko March 21, 2011, at 02:40 PM

Comment lier cette recette avec notify ?

Les membres peuvent choisir les pages à suivre, mais les mails ne sont pas envoyé... Pourtant, j'ai bien ajouté $EnableNotify = 1; dans config.php

Il y a un truc que je ne comprend pas !

Merci d'avance !Manu February 22, 2012, at 02:55 PM

Pour chaque utilisateur, il faut ajouter dans SiteAdmin.NotifyList une telle ligne:
notify=adresse@domaine.fr trail=Profiles.Petko-Watchlist
où après notify= c'est l'adresse de l'utilisateur, et après trail= c'est sa propre page avec sa liste de suivi, définie avec $WatchlistTrailFmt. Effectivement, le module fonctionne comme les listes de suivi sur Wikipédia, avec une page spéciale à chaque utilisateur; pour des envois avec Notify il faut bidouiller un peu. --Petko February 22, 2012, at 04:21 PM

Merci ! Je vais tester ça ! Je vais utiliser une requête SQL via php pour le faire automatiquement dans config.php

 
$EnableNotify = 1;		
	include_once("$FarmD/cookbook/adodb/adodb.inc.php");
	$DB['mysql'] = NewADOConnection('mysql');  
	if (!$DB['mysql']) die("Connection failed"); 
	$DB['mysql']->Connect('mysqlxxxxxxxx', 'xxxxxxxxxx', 'xxxxxxxxxx', 'xxxxxxxxx');
	$rs = $DB['mysql']->Execute("SELECT email,username FROM pmwiki_users");
	if ($rs){
        while ($arr = $rs->FetchRow()) {
		$monMail=$arr['email'];
		$monPseudo=$arr['username'];
		$NotifyList[] = 'notify='.$monMail.' trail=Watchlists.'.$monPseudo.'';  
        } 
	}

Manu? February 22, 2012, at 11:47 PM

Talk page for the AddToWatchlist recipe (users).

Edit - History - Print - Recent Changes - Search
Page last modified on February 22, 2012, at 11:47 PM