Closed Remigr closed 5 years ago
Mmmh... So I found the way to do it with this hook https://www.mediawiki.org/wiki/Manual:Hooks/InitializeArticleMaybeRedirect. But it means that at every page loading we will do a database query before loading the page, to see if it's a spot. Is it really useful to do this, knowing that nobody should go to a spot article ? There is never a link to a spot article. What do you think @simison @omelnyk ?
I'd try to hook in at the moment when article is already parsed (so we'll have categories) and see if it's not too late to make header redirect at that point.
Otherwise I'd just add this to JS:
if(mw.config.get('wgAction') == 'view') {
// mw.config.get('wgCategories')
}
Another idea: how about namespacing spots? Spot:Title, not sure what that requires tho.
Last solution is cool. Something like that :
$wgHooks['InitializeArticleMaybeRedirect'][] = 'spotInitializeArticleMaybeRedirect';
function spotInitializeArticleMaybeRedirect(&$title, &$request, &$ignoreRedirect, &$target, &$article){
if (substr($title, 0, 5) === 'Spot:') {
//Query id in database
// ........
//then
$target = "Special:HWMap?spot=".$id;
}
}
If we do that we need to change the migration script to add "Spot:" to the title of the spots.
https://www.mediawiki.org/wiki/Manual:Using_custom_namespaces
Cool, we'll be able to separate spots / articles count.
We've got table with migrated spot article ids somewhere. Renaming their titles should be trivial SQL update directly to the DB. @omelnyk ?
+1 for the namespaces
@simison supposedly so; not sure if MediaWiki keeps page titles anywhere but the page table. Either way I'd better modify the migrate script accordingly, and give spot pages proper names in the first place.
The spot article pages are not so useful. We should hook into mediawiki to redirect to the map, open the right spot, locate it on the map.