模板:Transclude random excerpt
此模板使用Lua語言: |
Transclude random excerpt transcludes the lead of an article as an excerpt. It is designed for use in portals. It returns the text of an article up to but excluding the first header, after removing:
- initial templates such as infoboxes, hatnotes and article improvement tags
- noinclude sections
- references and footnotes
- images, unless specifically retained
Usage
編輯{{Transclude random excerpt | 1= | 2= | paragraphs= | files= | fileargs= | errors= }}
The template accepts any number of page names as unnamed parameters. One of them is selected randomly, and the page with that title is transcluded. (If the selected page is invalid, the template will choose again.) Include a namespace where necessary. There are no other positional parameters, but there are some optional named parameters:
- A list of paragraphs such as
paragraphs=1,3-5
; the default is all paragraphs. - A list of file (image) numbers such as
files=1
; the default is no images. Non-free images are removed. - Arguments to pass to File: such as
fileargs=left
to move images to the left; the default is none. errors=
to allow Lua error messages to appear in the outputshowall=
to show all articles simultaneouslylist=
to show a list of articles coding not compatible with mobile versions of Wikipedia causing display and accessibility problems
paragraphs=
and files=
each accept a comma-separated list containing numbers and/or number ranges in the format min-max. Alternatively, files=
can accept the name of a single image, e.g. files=My image file.jpg
.
showall=
shows all articles simultaneously. This option is intended for a subpage aimed at editors as well as readers. Using this template on a subpage with <noinclude>|showall=</noinclude>
and transcluding the subpage on a main page will show all excerpts on the subpage but only one on the main page, without repeating the template and its arguments.
Miscellaneous options
編輯|more=no
– to suppress link to the article at the end of the excerpt.|more=custom text
to customize the link text at the end of the excerpt. Default is "Full article...".keepSubsections=1
will cause Article#Section to retain any subsections of that sectionkeepRefs=1
will keep references for display in a {{reflist}} or similarnobold=1
will cause bold text to be displayed in normal font
Page options
編輯Each page to be transcluded may be specified either plain or as a wikilink, possibly piped. Links to sections also work, and extract the named section rather than the lead. Examples: Article
; Article#Section
; [[Article]]
; [[Article#Section|A section of an article]]
. (Any piped text will be ignored.)
Any of the above formats may be followed by option(s) separated by pipes, e.g. Article|paragraphs=2
. Such options override any global options for the given page only. Note that the characters |
and =
have special meaning within calls to templates but can be escaped using {{!}} and {{=}} respectively. Examples: Article#Section{{!}}files{{=}}2
; [[Article|Some page]]{{!}}files{{=}}3,4{{!}}more{{=}}Click here
. (=
need not be escaped if the parameter is explicitly numbered, e.g. 1=Article{{!}}files=2
).
Special characters such as pipes within page options must be doubly escaped, replacing their double braces by {{((}} and {{))}}. For example, to set display Custom image.jpg on the left with a custom caption, set fileargs to left|Custom caption
using Article{{!}}files{{=}}Custom image.jpg{{!}}fileargs{{=}}left{{((}}!{{))}}Custom caption
. To add a wikilink within a caption, escape the link brackets and any pipe twice using {{!((}}, {{))!}} and possibly {{!}}, e.g. Caption with {{((}}!(({{))}}Pipe (computer science){{((}}!{{))}}piped{{((}}))!{{))}} link
. This text can be achieved more simply using {{Doubly escaped wikilink}}, e.g. Caption with {{Doubly escaped wikilink|Pipe (computer science)|piped}} link
.
See also
編輯- {{Transclude lead excerpt}}: specifies the article explicitly
- {{Transclude list item excerpt}}: chooses the article randomly from those listed on a page
- {{Transclude linked excerpt}}: chooses the article randomly from those linked from a page
- {{Transclude selected excerpt}}: chooses the article from a list using an index such as the week number
The templates were discussed at Use of direct transclusion in portals and the newer portal transclusion templates.
TemplateData
編輯Transclude random excerpt transcludes the lead of a randomly chosen article as an excerpt
參數 | 描述 | 類型 | 狀態 | |
---|---|---|---|---|
1 | 1 | The name of a page which may be transcluded
| 字串 | 必填 |
2 | 2 | The name of another page which may be transcluded. Similarly for optional parameters 3, 4, ...
| 字串 | 非必填 |
Paragraphs | paragraphs | Numbers of the paragraphs to be transcluded, as a comma-separated list containing numbers and/or number ranges in the format min-max
| 字串 | 非必填 |
Files | files | Numbers of the images to be transcluded, as a comma-separated list containing numbers and/or number ranges in the format min-max
| 字串 | 非必填 |
FileArgs | fileargs | Arguments to pass to File:
| 字串 | 非必填 |
More | more | Text for trailing link to the entire article. Note: more= with no value produces the standard text: Read more...
| 字串 | 非必填 |
Errors | errors | Allow Lua error messages to appear in the output?
| 布林值 | 非必填 |
ShowAll | showall | Show all excerpts simultaneously?
| 字串 | 非必填 |
List | list | Show a list of excerpts?
| 字串 | 非必填 |