Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

RandomPage

Summary: Include a random wiki page from a supplied list of pages.
Version: 1.0
Status: Obsolete
Prerequisites: pmwiki-2.0
Maintainer: ccox
Categories: Includes
Votes:

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*(.*?):\\)/e",
         "randomPage('$1')");

    function randomPage($opts) {
         $args = ParseArgs($opts);
         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:)
Thisis
Banner5

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:)

Total Commerce from 8 to 5

Have you ever seen a developer at 8am in the morning? Not a pretty sight. And 5pm, come on! We're just finishing the pizza.. probably from the night before. No coffee, no code, no pizza, no late nights, no commerce. Got it dude!
We Make Great Products (when we're awake)

-- Pm March 08, 2006, at 04:50 PM

See Also

Contributors

Chris Cox


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.

Edit - History - Print - Recent Changes - Search
Page last modified on June 05, 2013, at 03:27 PM