Manual:LinkRenderer.php

  is a class to create HTML links for a specific title. It was refactored out of the  class in MediaWiki 1.28.

Getting a LinkRenderer instance
In general, the easiest way to get a   instance is from  :

This will provide you with an instance prepared for the current user ( ).

Some contexts will have their own LinkRenderer instance, like the  or :

If you need to set custom options (see below), you can create your own! You shouldn't modify the main instances since that will affect the entire request state.

Making links
Okay, you now have a <tvar|1>LinkRenderer</> instance. Let's make some links! At the very minimum you'll need a <tvar|1> </> or <tvar|2> </> target to link to. The examples below all use <tvar|1>TitleValue</> for simplicity, but the equivalent <tvar|2>Title</> object can be used as well.

Will give you:

If you want to change the link text:

This text will automatically be escaped (different from its Linker predecessor). If you need to include HTML, you can armor the content:

Options
LinkRenderer has a few options that are set per-instance and can be customized:


 * ForceArticlePath ( / ) - Forces the link to use the article path (see <tvar|1></>) even if a query string is present, resulting in URLs like <tvar|2> </>.
 * ExpandURLs ( / ) - Controls whether the URL should be expanded, and can be set to any of the <tvar|1> </> constants.
 * StubThreshold ( / ) - Threshold at which articles should be marked with the <tvar|1> </> CSS class. Using <tvar|1> </> will automatically set this.