Valve Developer Community:Sandbox: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (added headings and toc)
Line 38: Line 38:
?></source>
?></source>
==Parser function hooks==
==Parser function hooks==
* fullurl:{{fullurl:MDL | hi }}
* fullurl:{{fullurl:MDL|hi}}
* urlencode:{{urlencode:123!"§ | 456$%& }}
* urlencode:{{urlencode:123!"§}}
* uc:{{uc:x|y}}
* uc:{{uc:x}}
* uc:{{uc:xyz}}
* ucfirst:{{ucfirst:xyz}}
anchorencode, defaultsort, displaytitle, filepath, formatnum, fullurl, fullurle, grammar, int, language, lc, lcfirst, localurl, localurle, ns, numberofadmins, numberofarticles, numberofedits, numberoffiles, numberofpages, numberofusers, padleft, padright, pagesincategory, pagesize, plural, special, tag, uc, ucfirst and urlencode
anchorencode, defaultsort, displaytitle, filepath, formatnum, fullurl, fullurle, grammar, int, language, lc, lcfirst, localurl, localurle, ns, numberofadmins, numberofarticles, numberofedits, numberoffiles, numberofpages, numberofusers, padleft, padright, pagesincategory, pagesize, plural, special, tag, uc, ucfirst and urlencode

Revision as of 13:00, 20 January 2009

The Sandbox (Valve Developer Community:Sandbox) is a VDC namespace page designed for testing and experimenting with Wiki syntax. Feel free to try your skills at formatting here: click on edit, make your changes, and click 'Save page' when you are finished. Content added here will not stay permanently.

Please do not edit the "markup" text, at the top of the editing window, that reads "{{sandbox}}".


Parser extension tags

newsblurbs:<newsblurbs>dfgdfg dfgdfg dfgdfg</newsblurbs> nframe:<nframe>dfgdfg dfgdfg dfg</nframe>

pre:

dfgdfg dfgdf
dfgdfg dfgfgdf
dfgdf fdggd

source:

<?php
 
# Define a setup function
$wgExtensionFunctions[] = 'efExampleParserFunction_Setup';
# Add a hook to initialise the magic word
$wgHooks['LanguageGetMagic'][]       = 'efExampleParserFunction_Magic';
 
function efExampleParserFunction_Setup() {
        global $wgParser;
        # Set a function hook associating the "example" magic word with our function
        $wgParser->setFunctionHook( 'example', 'efExampleParserFunction_Render' );
}
 
function efExampleParserFunction_Magic( &$magicWords, $langCode ) {
        # Add the magic word
        # The first array element is case sensitive, in this case it is not case sensitive
        # All remaining elements are synonyms for our parser function
        $magicWords['example'] = array( 0, 'example' );
        # unless we return true, other parser functions extensions won't get loaded.
        return true;
}
 
function efExampleParserFunction_Render( &$parser, $param1 = '', $param2 = '' ) {
        # The parser function itself
        # The input parameters are wikitext with templates expanded
        # The output should be wikitext too
        $output = "param1 is $param1 and param2 is $param2";
        return $output;
}
?>

Parser function hooks

anchorencode, defaultsort, displaytitle, filepath, formatnum, fullurl, fullurle, grammar, int, language, lc, lcfirst, localurl, localurle, ns, numberofadmins, numberofarticles, numberofedits, numberoffiles, numberofpages, numberofusers, padleft, padright, pagesincategory, pagesize, plural, special, tag, uc, ucfirst and urlencode