Module:Redirect/doc
![]() | This is a documentation subpage for Module:Redirect. It may contain usage information, categories and other content that is not part of the original module page. |
![]() | This Lua module is used in system messages, and on approximately 4,790,000 pages, or roughly 8% of all pages. Changes to it can cause immediate changes to the Wikipedia user interface. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them. |
![]() | This module depends on the following other modules: |
This module contains functions to find the target of a redirect page.
Main
- <t lang="lua">
local mRedirect = require('Module:Redirect') </syntaxhighlight>
Then use the function with the following synt < lang="lua"> mRedirect.luaMain(rname, bracket) </syntaxhighlight>
rname is the name of the redirect page, and if bracket is anything but false or nil, the module will produce a link rather than just a page name.
IsRedirect
The isRedirect function is used from wiki pages to find out if a given page is a redirect or not. If the page is a redirect, the function returns "yes", and if not the output is blank. Its usage is {{#invoke:redirect|isRedirect|page-name}}
.
Examples
- <l mRedirect = require('Module:Redirect')
mRedirect.luaIsRedirect(rname) </syntaxhighlight>
GetTarget
The getTarget function fetches the target page name of a redirect page, and is only usable from Lua. If the page specified is a redirect, then the target is returned; otherwise the function returns nil.
To use it, first load the module.
<syntaxhighlight lang="lua"> local mRedirect = require('Module:Redirect') uses this module