Summary: How to create pages that refresh automatically.
Version: 2006-09-26
Prerequisites: pmwiki-2.0 (and possibly earlier)
Status: stable
Categories: Layout


This recipe makes it possible for a page to refresh at set intervals, or by an interval set in a ?refresh=nn addition to a page URL.


general automatic page refresh

The following will cause a browser to refresh the page every 30 seconds:

if ($action == 'browse')
    $HTMLHeaderFmt['refresh'] =
       "<meta http-equiv='Refresh' Content='30; URL={\$PageUrl}' />";

It can be done sitewide in local/config.php (probably not recommended, because it will work for all pages), or in a per-page or per-group customization file.

refresh markup

Alternatively, set individual page refresh with markup directive.
Example: page refresh every 20 seconds: (:refresh 20:)

# markup (:refresh nn:)
Markup('refresh', '<include',
  "RefreshMarkup(\$pagename, PSS('$1'))");

function RefreshMarkup($pagename, $secs) {
        global $HTMLHeaderFmt;
            $HTMLHeaderFmt['refresh'] =
               "<meta http-equiv='Refresh' Content='$secs; URL={\$PageUrl}' />";
        return '';

refresh url parameter

Or, one could use the following customization to add a '?refresh=nn' option to all pages:

if (@$_GET['refresh']) {
   $r = $_GET['refresh'];
   $HTMLHeaderFmt['refresh'] =
     "<meta http-equiv='Refresh' Content='$r; URL={\$PageUrl}?refresh=$r' />";

As a demonstration, this latter version is enabled at: Test.Refresh.

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See Also

  • SlideshowRefresh - uses the code above as a basis for a recipe that enables "slideshows" consisting of wikipages getting automatically loaded, one-after-another, via the Refresh meta tag.



See discussion at AutomaticPageRefresh-Talk

User notes? : 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.