blob: d99795afaa7924ae6a233c0cf6181d7d1f876e53 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<?php
class CategoryByListHooks {
// Register any render callbacks with the parser
public static function onParserFirstCallInit( Parser $parser ) {
// Create a function hook associating the "example" magic word with CategoryByList()
$parser->setFunctionHook( 'CategoryByList', [ self::class, 'CategoryByList' ] );
}
// Render the output of {{#example:}}.
public static function CategoryByList( Parser $parser, $param1 = '', $param2 = '', $param3 = '' ) {
// The input parameters are wikitext with templates expanded.
// The output should be wikitext too.
$output = "";
$categories = explode(', ', $param1);
foreach ($categories as $item) {
$output .= '[[CategorÃa:'.$item.']]';
}
return $output;
}
}
|