RandomQuote

Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.


Goal

Insert a random quote into a wiki page.

Solution

Attach:randomquote.zip

randomquote.zip unpacks into local/quote.php and pub/quotes.txt.

Discussion

Randomquote adds the markup [[randquote]] which will be replaced by a randomly chosen line from quotes.txt. The line is enclosed in a div with id=randquote.

The format for quotes.txt is one quote per line with pipes ( | ) used to denote line breaks within the quote. Each pipe will be replaced with <br> before the quote is inserted.

I've noted one CSS related problem. Margins and padding on the div randquote don't seem to work.

You can see it in action at: http://wiki.thunderbunny.org/GeekStuff/RandomQuote

Contributor

  • Dave Noonan

For a different version that takes the quotes from a Wiki page have a look at my markup extension at http://www.b-a-l-u.de/index.php/Projects/RandomQuote -- Balu (2004-03-22)


I extended Balu's version of randomquote.php to use CSS (Attach:randomquote-thom.php.txt). For an example see http://beeblebrox.net.

--thom pmwiki-2.5.9 -- Last modified by {{thom}}

from IP: 85.171.160.186 ip should be disabled by default for security reasons

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%2dV1%2fRandomQuote
            [REDIRECT_HTTPS] => on
            [REDIRECT_QUERY_STRING] => n=Cookbook%2dV1%2fRandomQuote
            [REDIRECT_SCRIPT_URI] => https://www.pmwiki.org/wiki/Cookbook-V1/RandomQuote
            [REDIRECT_SCRIPT_URL] => /wiki/Cookbook-V1/RandomQuote
            [REDIRECT_SSL_TLS_SNI] => www.pmwiki.org
            [REDIRECT_STATUS] => 200
            [REDIRECT_UNIQUE_ID] => afR_VjHdntCX_VEKOhRa0gAAAQo
            [REDIRECT_URL] => /wiki/Cookbook-V1/RandomQuote
            [REMOTE_ADDR] => 216.73.216.25
            [REMOTE_PORT] => 20759
            [REQUEST_METHOD] => GET
            [REQUEST_SCHEME] => https
            [REQUEST_URI] => /wiki/Cookbook-V1/RandomQuote
            [SCRIPT_FILENAME] => /home/pmwiki/public_html/index.php
            [SCRIPT_NAME] => /index.php
            [SCRIPT_URI] => https://www.pmwiki.org/wiki/Cookbook-V1/RandomQuote
            [SCRIPT_URL] => /wiki/Cookbook-V1/RandomQuote
            [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] => afR_VjHdntCX_VEKOhRa0gAAAQo
            [PHP_SELF] => /index.php
            [REQUEST_TIME_FLOAT] => 1777631062.7406
            [REQUEST_TIME] => 1777631062
            [argv] => Array
                (
                    [0] => n=Cookbook%2dV1%2fRandomQuote
                )

            [argc] => 1
        )

)