Summary: How to display a list of last n RecentChanges
Version: 1
Maintainer: Petko
Categories: Administration, Links, PHP72


How can I display only a list of the last n pages modified on a site, e.g., in a sidebar?


The simple answer is to do a partial include of a "recent changes" page, as in:

(:include Site.AllRecentChanges lines=5:)

Unfortunately, with the author, date, and other information the default format for the recent changes pages is a bit long to display in a sidebar.

One solution is to use a "pagelist trail":

(:pagelist trail=Site.AllRecentChanges count=5 fmt=#simple:)

Another solution is to define other recent changes pages that have exactly the format we want. The following can be placed in local/config.php:

    $RecentChangesFmt['Site.LastChanged'] = '* [[$Group.$Name]]  ';

This says to create and maintain a page called Site.LastChanged that contains a simple bullet list of only the page names of recently changed pages on the site. Note that the two spaces at the end of the format string are required.

The RecentChanges code uses these two spaces to determine

  1. that line is formatted by RecentChangesFmt, and
  2. where the page-name-specific information ends (for removing the appropriate lines when updating page).

The RecentPages page will only contain those edits that happened after you configured it. So it will be empty until the first edit.

Once this page has been created, one can easily do the following to display the names of the last five recently changed pages on a site:

(:include Site.LastChanged lines=5:)


I added the line starting "The RecentChanges code" based on a message on the mailing list. menachem January 29, 2005, at 09:40 PM


How do I make RecentChanges actually show AllRecentChanges?


Add the following to config.php

 if (preg_match('![./]RecentChanges$!', $pagename))
     $DefaultPageTextFmt = '(:include Site.AllRecentChanges:)';
  • Note that for this to work you should delete all the existing RecentChanges pages.

Another solution: Redefine in config.php or a specific Group.php:

    $RecentChangesFmt['$Group.RecentChanges'] = '(:include Site.AllRecentChanges:)';

You would not need to delete any pages for this. - HansB


  • Pm, 2004-12-29


Even though I use the lines=5 option, it gives me a list of all the changes. So the lines option is ignored. How can I fix that?


To be able to use the lines=5 option, you'll have to use the Markup directive instead of the Wiki directive. Example of the template code:

<!--markup:(:include Site.AllRecentChanges lines=5:)-->


This only lists the first 5 records from RecentChanges... but not the 5 last records !!!! How to fix that?


This is what I used in mine and seems to work just how you looking for
(:include Site.LastChanged count=-10:) Tearstar? May 03, 2008, at 04:45 PM


Why not just use a pagelist?

(:if false:)
* [[{=$FullName} | {=$Titlespaced}]]

(:pagelist group=Site order=-ctime list=normal fmt=#titleonly count=4:)

This allows you to show only a specific group and exclude certain pages with name=-excludedpage and "list=normal" disallows the display of pages like `AllRecentChanges, `RecentChanges, `GroupHeader, etc.

See also

Categories: Layout, GUI

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.