RandomQuoteWiki

Summary: How to display a random quote from a list stored in a PmWiki page
Version:
Prerequisites: requires at least PmWiki version: 2.0; last tested on PmWiki version: 2.0.0
Status:
Maintainer: cda (other recipes)
Categories: Administration

Question

How can I display a random quote from a list stored in a PmWiki page, and not from a flat file that I cannot access easily ?

Answer

Copy RandomQuoteWiki.phpΔ to the cookbook directory and add include_once("cookbook/RandomQuoteWiki.php"); to config.php.

Notes and Comments

This script adds two markups (:RandomQuoteWiki_quote:) and (:RandomQuoteWiki_author:) that contain a random quote stored in a pmwiki page (instead of a flat file that cannot be accessed by most users).

The quotes must be structured like

    <quotes>
       <quote>
          <text>quote text 1</text>
          <author> quote author 1</author>
       </quote>
       <quote>
          <text>quote text 2</text>
          <author>quote author 2</author>
       </quote>
       ...
    </quotes>

See Also

The latest version is available here.

Contributors

Christophe David original script

Array
(
    [post_max_size] => 64M
    [$_POST keys] => 
    [$_REQUEST keys] => n
    [$_SERVER] => Array
        (
            [CONTEXT_DOCUMENT_ROOT] => /home/pmwiki/public_html
            [CONTEXT_PREFIX] => 
            [DOCUMENT_ROOT] => /home/pmwiki/public_html
            [GATEWAY_INTERFACE] => CGI/1.1
            [HTTPS] => on
            [HTTP_ACCEPT] => */*
            [HTTP_ACCEPT_ENCODING] => gzip, br, zstd, deflate
            [HTTP_HOST] => www.pmwiki.org
            [HTTP_USER_AGENT] => Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
            [HTTP_X_HTTPS] => 1
            [PATH] => /bin:/usr/bin
            [PHP_INI_SCAN_DIR] => /opt/cpanel/ea-php70/root/etc:/opt/cpanel/ea-php70/root/etc/php.d:.
            [QUERY_STRING] => n=Cookbook%2fRandomQuoteWiki
            [REDIRECT_HTTPS] => on
            [REDIRECT_QUERY_STRING] => n=Cookbook%2fRandomQuoteWiki
            [REDIRECT_SCRIPT_URI] => https://www.pmwiki.org/wiki/Cookbook/RandomQuoteWiki
            [REDIRECT_SCRIPT_URL] => /wiki/Cookbook/RandomQuoteWiki
            [REDIRECT_SSL_TLS_SNI] => www.pmwiki.org
            [REDIRECT_STATUS] => 200
            [REDIRECT_UNIQUE_ID] => afQpi4YPebMfs4MUkgU8qgAAARI
            [REDIRECT_URL] => /wiki/Cookbook/RandomQuoteWiki
            [REMOTE_ADDR] => 216.73.216.25
            [REMOTE_PORT] => 40760
            [REQUEST_METHOD] => GET
            [REQUEST_SCHEME] => https
            [REQUEST_URI] => /wiki/Cookbook/RandomQuoteWiki
            [SCRIPT_FILENAME] => /home/pmwiki/public_html/index.php
            [SCRIPT_NAME] => /index.php
            [SCRIPT_URI] => https://www.pmwiki.org/wiki/Cookbook/RandomQuoteWiki
            [SCRIPT_URL] => /wiki/Cookbook/RandomQuoteWiki
            [SERVER_ADDR] => 23.254.203.248
            [SERVER_ADMIN] => webmaster@pmwiki.org
            [SERVER_NAME] => www.pmwiki.org
            [SERVER_PORT] => 443
            [SERVER_PROTOCOL] => HTTP/1.1
            [SERVER_SIGNATURE] => 
            [SERVER_SOFTWARE] => Apache
            [SSL_TLS_SNI] => www.pmwiki.org
            [TZ] => America/Los_Angeles
            [UNIQUE_ID] => afQpi4YPebMfs4MUkgU8qgAAARI
            [PHP_SELF] => /index.php
            [REQUEST_TIME_FLOAT] => 1777609099.6178
            [REQUEST_TIME] => 1777609099
            [argv] => Array
                (
                    [0] => n=Cookbook%2fRandomQuoteWiki
                )

            [argc] => 1
        )

)