|
Cookbook /
AutomaticPageRefreshSummary: How to create pages that refresh automatically.
Version: 2006-09-26
Prerequisites: pmwiki-2.0 (and possibly earlier)
Status: stable
Maintainer:
Categories: Layout
DescriptionThis 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. Notesgeneral automatic page refreshThe 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 markupAlternatively, set individual page refresh with markup directive.
# markup (:refresh nn:)
Markup('refresh', '<include',
'/\\(:refresh\\s+(.*?):\\)/ei',
"RefreshMarkup(\$pagename, PSS('$1'))");
function RefreshMarkup($pagename, $secs) {
global $HTMLHeaderFmt;
$HTMLHeaderFmt['refresh'] =
"<meta http-equiv='Refresh' Content='$secs; URL={\$PageUrl}' />";
return '';
}
refresh url parameterOr, 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
CommentsSee AlsoContributors |