Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

NewsList

Summary: Insert a list of recently changed/updated wikipages in a short form.
Version: 29.11.05: Initial release
Prerequisites: Requires at least PmWiki version: pmwiki-2.1.beta5; last tested on PmWiki version: pmwiki-2.1.beta5.
Status:
Maintainer:
Categories: Blog, CMS

Questions answered by this recipe

How can I insert a list of recently changed/updated wikipages in a short form that can be used in the sidebar, for example?

Answer

Include this in your php files:

 Markup('news','fulltext','/\(:news\s*(.*?):\\)/e',"newsList('$1')");
function newsList ($arg) {
	global $WorkDir;
	$args = explode(" ",$arg);
	$reg = array();
	$max = 500;
	$exclude = false;
	$grps=array();
	foreach ($args as $i=>$val) {
		if (preg_match("/(\d+)/",$val,$max)) {
			$max = $max[1];
			continue;
		}
		if ($val=='not') {
			$exclude = true;
		}
		$grps[$val] = true;
	}
	$reg = "/^(.+?)\.[^,]+$/";

	$dir = opendir($WorkDir);
	$out = array();
	$files = array();
	while ($file = readdir ($dir)) {
		if (!preg_match($reg,$file,$grp)||preg_match("/.(All)*RecentChanges/",$file)) continue;
		$grp = $grp[1];
		if ($grps[$grp] xor $exclude)
			$files[filemtime("$WorkDir/$file")] = $file;
	}
	krsort($files);
	foreach($files as $i => $val) 
		if ($max--<=0) break; 
		else $out[]="*[[".str_replace(".","/",$val)."]] [--(".date("d.m.y",$i).")--]";
	closedir($dir);
	return implode("\n",$out);
}

This will create a indexlist sorted by date. It will skip the AllRecentChanges and RecentChanges pages and it only looks into specified groups, so this will need some administration from your side. Since I needed this script for a CMS like website, I didn't want to list the Site etc. groups. You can specify a maximum of listet changes by adding a number. Use it like this:

 (:news Main Cookbook 8:)

This will list the eight most recent changes (depending on the filechange dates in your wiki.d directory) in the Main and Cookbook group. You can also invert the used groups by applying a not to the arguments, i.e.

 (:news not Site:)

Comments

Peter Bowers May 18, 2011, at 12:09 AM: Or, perhaps use this rather than having a custom markup... (:pagelist group=X,Y,Z list=normal fmt=#myfmt:)

See Also

Contributors

  • Zet

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.

Edit - History - Print - Recent Changes - Search
Page last modified on September 10, 2011, at 11:42 AM