| 本頁面之全部或部分原來自MediaWiki的Extension:InputBox,依 CC BY-SA 3.0 授權引入;原貢獻者可以在這裡看到。 |
InputBox是一個MediaWiki擴展,可以創建用於搜索、新建、修改頁面的輸入框。
這個輸入框可以創建以輸入內容為標題的頁面。
<inputbox> type=create break=no </inputbox>
輸入框像這樣構造:
<inputbox> type= bgcolor= width= default= preload= editintro= buttonlabel= hidden= searchbuttonlabel= fulltextbutton= labeltext= break= namespaces= prefix= placeholder= page= minor= summary= id= inline= dir= preloadparams[]= searchfilter= useve= usedt= arialabel= </inputbox>
type參數必須輸入。 而其他所有參數均為可選。 preloadparams[]可以出現不止一次。
默認情況下提交按鈕位於輸入框的下面。
通過設置換行參數可將「提交」按鈕移至右側:break=no。
將「提交」按鈕移至右側對於使用搜索框時搜索建議覆蓋了下方搜索按鈕的情況很有用。
| 類型 | 例子 | 描述 |
|---|---|---|
| type=search | 創建的搜索框的默認寬度為50字符。 輸入的內容為要搜索的關鍵字。 | |
| type=create | 創建新頁面。 輸入的內容為要編輯的頁面名稱。 | |
| type=comment | 在輸入框指定的頁面下增加一個新段落。 | |
| type=commenttitle | 以輸入框中輸入的標題增加一個新段落。 標題可以用default=參數指定。頁面必須用page=參數指定。
| |
| type=fulltext | 僅顯示全文搜索按鈕,不顯示「前往」按鈕。 | |
| type=move | 將頁面移動至另一個名字。 |
對於type=search2,默認的搜索按鈕位置在右側。這種搜索框將搜索其所在的整個維基。
| 類型 | 例子 |
|---|---|
| type=search2 |
| 參數 | 描述 | 適用範圍 | 例子 | 結果 | |
|---|---|---|---|---|---|
| arialabel= | 為輸入框提供aria-label屬性,以允許屏幕閱讀器訪問生成的標記。 | 所有類型 | <inputbox> type=search arialabel=Search the Wiki </inputbox> |
||
| bgcolor= | 設置表格背景色(HTML顏色值)。 不要使用引號。 | 所有類型 | <inputbox> type=search bgcolor=#eeeeff </inputbox> |
||
| width= | 設置輸入框的寬度,單位為字符。 | 所有類型 | <inputbox> type=create width=24 </inputbox> |
||
| default= | 輸入框中的默認文本。 | 所有類型 | <inputbox> type=comment default=User_talk:示例用戶 </inputbox> |
||
| preload= | 當創建新頁面時,此標題的頁面將會被預先載入進空白編輯框。 | create, comment, commenttitle | <inputbox> type=create preload=Template:頁面格式/音樂 </inputbox> |
||
| 在上面或下面的輸入框示例中輸入一個不存在的頁面標題,並分別點擊「創建頁面」或「新段落」按鈕來測試此功能。 | |||||
| editintro= | 通過這一參數指定的頁面將會作為編輯指引顯示在編輯窗口上方。 |
create, comment | <inputbox> type=comment editintro=Template:Info </inputbox> |
||
| buttonlabel= | 此參數將作為表單主按鈕顯示的文字。 | 所有類型 | <inputbox> type=comment buttonlabel=添加新的段落 </inputbox> |
||
| hidden= | 此參數指定不顯示輸入框。
這需要與參數「default」配合使用,但此參數現在不是默認值,而是作為頁面標題的固定值。 |
create, comment | <inputbox> type=comment hidden=yes default=Help_talk:Inputbox buttonlabel=在該頁面討論頁留言 </inputbox> |
||
| searchbuttonlabel= | 此參數將作為表單「搜索全文」按鈕顯示的文字。 | search, fulltext | <inputbox> type=search searchbuttonlabel=深入探索 </inputbox> |
||
| fulltextbutton= | 在「search2」表單上顯示全文搜索按鈕。 | search2 | <inputbox> type=search2 searchbuttonlabel=深入探索 fulltextbutton=true </inputbox> |
||
| labeltext= | 在左側顯示的文字。 | search2 | <inputbox> type=search2 searchbuttonlabel=深入探索 labeltext=查找: </inputbox> |
||
| break= | 是否在輸入框和按鈕之間插入換行。 默認為yes(使用換行)。 | 所有類型 | <inputbox> type=create width=24 break=no </inputbox> |
||
| namespaces= | 在全文搜索中支持選擇命名空間。
使用「 |
search, fulltext | <inputbox> type=search namespaces=Main**,Help </inputbox> |
||
| prefix= |
註:下劃線不等同於空格。 |
search, fulltext, create | <inputbox> type=search prefix=Help: </inputbox> |
下面的按鈕以 | |
| placeholder= | 設置當輸入框為空時的佔位文字。 | 所有類型 | <inputbox> type=search placeholder=搜索萌娘百科 </inputbox> |
||
| minor= | 將編輯設置為小編輯。 | create | <inputbox> type=create page=Project:Sandbox minor=true </inputbox> |
||
| page= | 要發表評論或要移動的頁面。 | comment, move | <inputbox> type=comment page=Project:Sandbox </inputbox> |
||
| summary= | 編輯摘要或移動理由。 | create, move | <inputbox> type=create default=Special:Mypage/Inputbox_test summary=這是一段預設的編輯摘要 </inputbox> |
||
| id= | <form>的id屬性。 | 所有類型 | <inputbox> type=comment page=Project:Sandbox summary=Foo id=bar </inputbox> |
||
| inline= | 將輸入框作為inline元素(在開頭不換行)。 | search2 | 在此輸入: <inputbox> type=search2 inline=true width=10 </inputbox> |
在此輸入: | |
| dir= | 輸入框內的書寫方向,可以是從右到左(rtl)或從左到右(ltr)。 默認與頁面語言的方向相同。 | 所有類型 | <inputbox> dir=rtl type=create default=從右向左的文字 </inputbox> |
||
| preloadparams[]= | 設置預加載文本的參數。此例中的文本請見這裡 | create, comment, commenttitle | <inputbox> type=create preload=Help:Inputbox/預加載樣例 preloadparams[]=小明 preloadparams[]=小紅 </inputbox> |
||
| searchfilter= | 指定在搜索中追加的參數。 | search, fulltext | <inputbox> type=search searchfilter=insource:foo </inputbox> |
||
| useve= | 當該值不為空時,將使用可視化編輯器創建頁面。 | create, comment | <inputbox> type=create break=no useve=true </inputbox> |
||
| usedt= | 當該值不為空時,添加新段落時,輸入框將會打開討論頁工具的新話題工具。 | comment, commenttitle | <inputbox> type=commenttitle page=Help:沙盒 usedt=true </inputbox> |
||
對於已存在的頁面使用create只會跳轉到編輯界面。
在這種情況下preload被忽略。
對新頁面使用comment是有效的。
通過使用div標籤包裹的方法,可以調整一個輸入框的位置。
<div style="float:right; width:42em"> <inputbox> type=create break=no </inputbox> </div>
這時候這個輸入框就會浮動到右側。
輸入框可以在模板中使用。 然而,在模板中只有當<inputbox>...</inputbox>標籤以{{#tag:inputbox|...}}的形式編寫時,傳遞給輸入框的模板參數才能夠生效。
下面的例子是一個通過指定模板創建新頁面的模板:
{{#tag:inputbox|
type=create
buttonlabel=創建新{{{1|條目}}}
preload={{{2|Template:頁面格式/音樂}}}
}}
實例化此模板時,第一個參數提供一個已經創建好的項(默認為「條目」),就像按鈕中顯示的那樣。第二個參數提供用來創建項的模板名稱(默認為「Template:頁面格式/音樂」)。
| |||||||||||||||||||||||||||||||||||