Cookbook /
RandomPage
Summary: Include a random wiki page from a supplied list of pages.
Version: 1.0
Status: Obsolete
Prerequisites: pmwiki-2.2.58
Maintainer: ccox
Categories: Includes
Votes:
See the core documentation on PageLists with the order=random
option.
Overview
This allows you to create a random page include anywhere inside of a page. For example, you could have a random banner on a page.
Markup('randpage','<include',
"/\\(:randpage\\s*(.*?):\\)/",
"randomPage");
function randomPage($m) {
$args = ParseArgs($m[1]);
srand((float) microtime() * 10000000);
$randPageIndex = array_rand($args['']);
return "(:include " . $args[''][$randPageIndex] . ":)";
}
Insert the following into your page:
(:randpage Banners/Banner1 Banners/Banner2 Banners/Banner3 MyBanner/Thing:)
When that page is displayed it will include one of the pages given as arguments to the randpage directive.
For example:
(:randpage Banners/Banner1 Banners/Banner2 Banners/Banner3 Banners/Banner4 Banners/Banner5:) |
This is Banner 3 |
Notes and Comments
One can now include a random page by using the (:pagelist:)
markup:
(:pagelist group=Banners list=normal order=random count=1 fmt=#include:) |
Banner2 |
-- Pm March 08, 2006, at 04:50 PM
See Also
- RotateMarkup - randomly select markup to be displayed (obsolete)
- RandomQuote - Insert random quotes or markup into a page
- PmWiki.PageLists - examples using pagelist directive
- How to redirect to a random page (Wikipedia-style)
Contributors
Category: Includes
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.