FANDOM


Social-media-concept
Esempi Inputbox
Edit

Template:Extension

The InputBox extension is a MediaWiki extension that adds already created HTML forms to wiki pages. Users can "complete" a form (entering text, selecting menu items, etc.) by entering text into the box.

InputBox was originally created by Erik Möller for the purpose of adding a Create an article box to Wikinews.

Download Edit

Template:WikimediaGitCheckout

Installation Edit

  • For MediaWiki 1.17 (and possibly 1.18), use this revision of InputBox.hooks.php.

Template:ExtensionInstall

ExampleEdit

Box for starting a new article.

Wiki codeEdit

<inputbox>
type=create
break=no
</inputbox>

ResultEdit

General syntax Edit

InputBoxes are constructed like this:

<inputbox>
type=
bgcolor=
width=
default=
preload=
editintro=
buttonlabel=
hidden=
searchbuttonlabel=
break=
namespaces=
prefix=
placeholder=
</inputbox>

The type parameter is mandatory. All other parameters are optional.

Box types Edit

The default location of the submit button(s) is below the input box. The submit button can be moved to the right by using the line break parameter to eliminate the line break between the input box and the submit button: break=no

Having the submit button to the right is useful for search boxes when search suggestions would otherwise cover up a search button below the search box.

Type Example Description
type=search
Creates a search box which has a default width of 50 characters. Information added in the text box is searched for.
type=create

Creates a new page. Information added in the text box is the name of the page which is edited.
type=comment

Adds a new section to the bottom of the page specified in the text box.
type=commenttitle

Adds a new section with the section header typed into the text box. The page has to be specified with page= parameter. Added in rev:42703.
type=fulltext
Search only with the fulltext search button, without the 'Go' button. Added in rev:45269.

For type=search2 the default location for the search button is to the right. Currently, it does not seem to be possible to add other parameters to this type of input box. This search box searches the entire wiki that it is placed on.

Type Example
type=search2
 

Parameters Edit

Parameter Description Scope Compatibility Example Result
bgcolor= Sets the table background color (HTML color values). Do not use quotes. All types ?
<inputbox>
type=search
bgcolor=#eeeeff
</inputbox>
width= Sets the width of the InputBox in characters. All types ?
<inputbox>
type=create
width=24
</inputbox>

default= Default text to put in the InputBox. All types ?
<inputbox>
type=comment
default=User talk:Eloquence
</inputbox>

preload= The page under this title will be preloaded (see Manual:Creating pages with preloaded text) into the blank editbox when a new page is created. comment, create ?
<inputbox>
type=create
preload=Log
</inputbox>

Enter the title of a non-existent page in the example InputBox above or below, and click "Create article" or "Post a comment" respectively to test this effect.
editintro= The page which is given under this parameter will be shown, as instructions, above the editing window. comment, create ?
<inputbox>
type=comment
editintro=MediaWiki:Missingcommenttext
</inputbox>

buttonlabel= This label will be used for the main button of the form. All types ?
<inputbox>
type=comment
buttonlabel=Add new rumor
</inputbox>

hidden= This specifies that there is no inputbox.
It is used with parameter "default", now not being a default, but the fixed value of the name of the page.
create, comment ?
<inputbox>
type=comment
editintro=Extension:InputBox/editintro comment
preload=Extension:InputBox/preload
hidden=yes
default=Extension talk:Inputbox
buttonlabel=Post a comment on the talk page
</inputbox>

searchbuttonlabel= This label will be used for the "Search full text" button of the search form. search, fulltext ?
<inputbox>
type=search
searchbuttonlabel=Dig deeper
</inputbox>
break= Whether or not to insert a line break between the input box and the button(s). Defaults to yes (use a line break). All types ?
<inputbox>
type=create
width=24
break=no
</inputbox>
namespaces= Support for namespace checkboxes in fulltext search.
With "Namespace**" it is checked by default.
search, fulltext ?
<inputbox>
type=search
namespaces=Main**,Help
</inputbox>
prefix= Narrow down search to pages beginning with certain prefix. Note this only works with certain search backends, currently only latest Extension:lucene-search.
Defaults to empty string (search all pages).

Create new page beginning with a certain prefix.

Remark: underscores aren't recognised as spaces.

search, fulltext, create ?
<inputbox>
type=search
prefix={{FULLPAGENAME}}/Archive
</inputbox>

The button below prefixes the name with Special:Mypage/.


placeholder= Define placeholder text that will display in the input box when it is empty. All types 1.19+
<inputbox>
type=search
placeholder=Search this Wiki
</inputbox>

Applying create  to an existing page simply gives the edit page. In that case preload is ignored. Applying comment  for a new page works.

The texts taken from the MediaWiki: namespace are of course only examples, any existing page can be used for editintro or preload. Unfortunately preload does not yet work for the Special:Upload summary.

Template:Note

Alignment enhancementEdit

If there is a need to define alignment each time an input box is used, one option is to just remove the div tag from the input box HTML and specify the div when posting the InputBox. A more versatile option would be to add the following code which allows changing the alignment in the options. By installing this modified copy of the code then you can specify align=left, align=center, or align=right. Caution! The linked code is from Feb.2007. There have been bug fixes and feature additions to both MediaWiki and InputBox since that time. You may need to test for compatibility and functionality.

Using InputBox in a templateEdit

In order to create many similar input boxes, InputBox can be used in a template. However, passing template parameters to InputBox parameters only works if the <inputbox>...</inputbox> tag is written as {{#tag:inputbox | ...}} inside the template.

The following example is a template to create a new wiki page from a named template:

{{#tag:inputbox |
type=create
buttonlabel=Create new {{{1|article}}}
preload={{{2|Template:Article}}} }}



When instantiating the template, the first parameter gives the item that is created (default: article) as spelled out in the button, the second parameter gives the name of the template used to create the item (default: Template:Article).

E.g., the code for an input box to create a new project from a project template might look like this:

{{Template:CreateNew|project|Template:Project}}

See alsoEdit


Template:OnWikimedia

Template:Languages


   Statistiche
  • 26 articoli
  • 28 immagini
  • 639 modifiche effettuate
  • 0 utenti attivi



Pagina02  Contenuto della pagina

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.