Hi Valerio!
Thank you for looking into this.
Reviewing these links implies that this requires an extension? So it cannot be done simply, directly from LocalSettings.php?
Could you provide please a minimal example how to set as $CUSTOM_VARIABLE = "custom-content";?
Template are generally awesome but won't work here.
The use case here is multiple domain support, an alternative domain name accessing the same wiki/database, which already works great for me.
What I really want to set is something similar to
{{SERVER}} = //www.example.com {{SERVERNAME}} = www.example.com
But I only need
{{CUSTOM_APEX_DOMAIN_NAME}} = example.com
The use case in mediawiki markup would then be:
[{{protocoll_handler}}://forums.{{apex_domain_name}} our forums]
(I.e. "relative domain names which support sub domain changes")
This is the multiple domain support snippet which already works for me:
###
if (preg_match("/onion.onion/i", $_SERVER['SERVER_NAME'])) { $wgServer = 'http://www.onion.onion'; $wgCanonicalServer = 'https://www.example.com'; $wgAllowExternalImagesFrom = array( 'http://127.0.0.1/', 'http://www.onion.onion/' ); $wgRenderHashAppend = "www.onion.onion"; $wgCachePrefix = "www.onion.onion"; $wgFileCacheDirectory = "$IP/cache/www.onion.onion"; $wgLocalisationUpdateDirectory = "$IP/cache/www.onion.onion"; $wgCacheDirectory = "$IP/cache/www.onion.onion"; $MY_FQDN = "http://www.onion.onion"; } else { $wgServer = '//www.example.com'; $wgCanonicalServer = 'https://www.example.com'; $wgAllowExternalImagesFrom = array( 'http://127.0.0.1/', 'https://www.example.com/' ); $wgRenderHashAppend = "www.example.com"; $wgCachePrefix = "www.example.com"; $wgFileCacheDirectory = "$IP/cache/www.example.com"; $wgLocalisationUpdateDirectory = "$IP/cache/www.example.com"; $wgCacheDirectory = "$IP/cache/www.example.com"; $MY_FQDN = "https://www.example.com"; }
###
If I had the snippet to add custom magic words to LocalSettings.php, then kinda what I would add there is this:
if (preg_match("/onion.onion/i", $_SERVER['SERVER_NAME'])) { $CUSTOM_APEX_DOMAIN_NAME = 'onion.onion'; } else { $CUSTOM_APEX_DOMAIN_NAME = 'example.com'; }
Basically, how would I make $CUSTOM_APEX_DOMAIN_NAME available from inside the mediawiki?
I've left the lengthy description of my use case out from my original post for brevity.
Kind regards, Patrick
Valerio Bozzolan:
Hi Patrick Here some documentation for your specific question: https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/ParserFu... https://www.mediawiki.org/wiki/Manual:Hooks/ParserFirstCallInit Having said that, do you really need it? Why not just a new template? Create a page [[Template:Something]] to use {{Something}}. -boz On mer, 2021-12-29 at 10:46 +0000, Patrick Schleizer via MediaWiki-l wrote:
Could you explain please how to add a custom magic word to mediawiki LocalSettings.php?
Example: When writing in the wiki {{CUSTOM_VARIABLE}} it will expand to: custom-content
In other words... I want to set in LocalSettings.php
$CUSTOM_VARIABLE = "custom-content";
and that custom variable should then be available inside the wiki be as {{CUSTOM_VARIABLE}}.
If avoidable, writing a mediawiki extension should be avoided.
Is this possible?
Cheers, Patrick _______________________________________________ MediaWiki-l mailing list -- mediawiki-l@lists.wikimedia.org To unsubscribe send an email to mediawiki-l-leave@lists.wikimedia.org https://lists.wikimedia.org/postorius/lists/mediawiki-l.lists.wikimedia.org/
mediawiki-l@lists.wikimedia.org