Pergunta

I'm using MediaWiki. Some of the pages in the wiki contain one or more large navigation block, like the ones on the bottom of this page:

https://www.eftepedia.nl/

Blocks like these are included in many pages. Now, when a page is saved, the list of links to other pages is updated as well (pagelinks table). Those references are used by the 'What links here' special page and probably other similar pages as well.

But I actually don't want the links in these blocks to count for that. Is there a way I can influence MediaWiki to exclude some parts of a page in this updating-links-to-other-pages process?

I've written some extensions, overriden specific classes and used some hooks, so I know the basics of how that stuff works, but I cannot find the right hook to influence this part of the process.

As far as any attempts go, I've found ParserOutput::addLink, which is used to store parsed links into an array. Then, on save, this array is merged into the database. addLink is called from a couple of places, most notably from Parser::replaceInternalLinks2, which is called from Parser::internalParse.

If I understand correctly, internalParse is called for each piece of text separately. That includes separate includes, but also nested tags. Maybe I could use the hooks called in internalParse, but I haven't found the holy grail yet. I could use a push in the right direction to solve it, preferably without modifying the Parser class itself.

Foi útil?

Solução

The simplest way to get around this is by not using the [[wiki link]] syntax for the links. You can use external link syntax with full URLs [http://like/this like this] and make them look like regular internal links by wrapping them in a div or span with class="plainlinks". To make this less painful, make a template for that:

In Template:NaviLink, you would have:

<span class="plainlinks">[{{fullurle:{{{1}}}}} {{{2|{{{1}}}}}}]</span>

(yay for mediawiki's insane template syntax) (for an exmplanation of fullurle, see https://www.mediawiki.org/wiki/Fullurl#URL_data)

In your navigation template, you would then use e.g.:

* {{NaviLink|Efteling Golf course}}
* {{NaviLink|Haunted Castle (Efteling)|Haunted Castle}}

Instead of the NaviLink template, you could also implement a parser function (not a hook) that outputs the HTML for the desired link, without putting anything into the database. I don't see why you would do this, but if you want to, have a look at https://www.mediawiki.org/wiki/Manual:Parser_functions.

PS: internalParse is not called separately for included bits of text. Template expansion is done by the preprocessor before the actual parser is run on the resulting wikitext.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top