summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/CategoryByList/CategoryByListHooks.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/CategoryByList/CategoryByListHooks.php')
-rw-r--r--www/wiki/extensions/CategoryByList/CategoryByListHooks.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/www/wiki/extensions/CategoryByList/CategoryByListHooks.php b/www/wiki/extensions/CategoryByList/CategoryByListHooks.php
new file mode 100644
index 00000000..d99795af
--- /dev/null
+++ b/www/wiki/extensions/CategoryByList/CategoryByListHooks.php
@@ -0,0 +1,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;
+ }
+}