上面链接的模板正是我所需要的,但实际上并没有像写的那样工作。对于将来有此需求的任何其他人,这是一个清理和更正的版本,它删除了有问题的字符串函数并完美运行:
{{#if: {{{form|}}}
| {{#ifexist: Form:{{{form|}}}
|
| <strong class="error">Warning! The form "{{{form|}}}" may not be a valid form name!</strong>
}}
|
}}<!---
-->{{#if: {{{form|}}}
| {{#ifeq: {{lc:{{NS:{{{namespace|}}} }} }}
| {{lc:{{{namespace|}}} }}
|
| <strong class="error">Warning! "{{{namespace}}}" may not be a valid namespace name!</strong>
}}
|
}}<!---
-->The next document number is '''<!--
-->{{#if: {{{namespace|}}} | {{{namespace|}}}: }}{{{prefix|}}}<!--
-->{{padleft:<!----------- (X+1) => 0000(X+1)
-->{{#expr:<!---------- 0000X+1 => (X+1)
-->{{replace|<!----- "Namespace:prefix0000X" => "0000X"
-->{{replace|<!-- "*[[Namespace:prefix0000X]]" => "Namespace:prefix0000X"
-->{{#dpl:<!-- return pages named "*[[Namespace:prefix0000X]]"
-->titleregexp =^{{{prefix|}}}[0-9]{{{{pad|5}}}}$<!--
-->| namespace = {{{namespace|}}}<!--
-->| order = descending<!--
-->| mode = userformat<!--
-->| format = ,%PAGE%<!--
-->| noresultsheader = {{padleft:0|{{{pad|5}}}|0}}<!--
-->| count = 1
}}
|/^([^{{!}}]+\{{!}}){1}([^\]]+).*/
|\2
}}
| {{#if: {{{namespace|}}} | {{{namespace|}}}:}}{{{prefix|}}}
|
}}
+1
}}
| {{{pad|5}}}
| 0
}}'''
----
{{#if: {{{form|}}}
| {{#forminput: {{{form|}}}
| {{{width|20}}}
| {{{prefix|}}}<!--
-->{{padleft:<!----------- (X+1) => 0000(X+1)
-->{{#expr:<!---------- 0000X+1 => (X+1)
-->{{replace|<!----- "Namespace:prefix0000X" => "0000X"
-->{{replace|<!-- "*[[Namespace:prefix0000X]]" => "Namespace:prefix0000X"
-->{{#dpl:<!-- return pages named "*[[Namespace:prefix0000X]]"
-->titleregexp =^{{{prefix|}}}[0-9]{{{{pad|5}}}}$<!--
-->| namespace = {{{namespace|}}}<!--
-->| order = descending<!--
-->| mode = userformat<!--
-->| format = ,%PAGE%<!--
-->| noresultsheader = {{padleft:0|{{{pad|5}}}|0}}<!--
-->| count = 1
}}
|/^([^{{!}}]+\{{!}}){1}([^\]]+).*/
|\2
}}
|{{#if: {{{namespace|}}} | {{{namespace|}}}:}}{{{prefix|}}}
|
}}
+1
}}
| {{{pad|5}}}
| 0
}}
| {{{buttonlabel|Add}}}
| {{#if: {{{namespace|}}} | namespace = {{{namespace|}}} }}
}}
| <includeonly><strong class="error">Warning! You haven't specified a SemanticForm for page creation! Please specify a SemanticForm name.</strong></includeonly>
}}<noinclude>{{documentation}}</noinclude>
和文档子页面:
{{documentation subpage}}
{{intricate template}}
== Parameters ==
All parameters to the template are optional.
{| class="wikitable"
|-
! form
| Specifies a SemanticForm name, which will handle the pages you create.
|-
! namespace
| Specifies a Namespace, which the new page will belong to.
|-
! prefix
| Specifies a title fragment, which will prefix the generated number
|-
! pad
| The number of digits required in the page number. The default value is "5".
|-
! width
| Sets the width of the input box. The default value is "20".
|-
! buttonlabel
| Sets the text of the Create button. The default value is "Add".
|}
== Example ==
<pre><nowiki>{{DPLSNMakerSF
| form = MBMA Document
| namespace =
| prefix = MBMA-
| pad = 5
| width = 30
| buttonlabel = Create
}}
</nowiki></pre>
== See also ==
[[mw:extension:DPL Page Name S/N Maker (using SemanticForms)]]