Personal tools


SimpleForms categorisation example

From OrganicDesign

Jump to: navigation, search

This example shows how the SimpleForms extension can be used to make a form allowing the user to categorise the current page. When an item is selected from the dropdown list, the forms content and regexp parameters are updated. The regexp parameter is used to prevent more than one occurence of the same category link. If there are no matching category links, then a new one will be appended.

{{#form:

	{{#input:type=hidden|name=title|value={{FULLPAGENAMEE}}}}
	{{#input:type=hidden|name=summary|value=<nowiki>Article category updated from [[SimpleForms categorisation example]]</nowiki>}}
	{{#input:type=hidden|name=caction|value=append}}
	{{#input:type=hidden|name=regexp|id=setcat-regexp}}
	{{#input:type=hidden|name=content|id=setcat-content}}

	{{#input: type   = select
		| *Select category{{#dpl: namespace = Category | mode = userformat | listseparators = ,\n*%TITLE%,, }}
		| onChange = 
			document.getElementById('setcat-regexp').setAttribute('value','\\[\\[Category:'+this.value+'.*?\\]\\]');
			document.getElementById('setcat-content').setAttribute('value','['+'[Category:'+this.value+']'+']');
	}}

	{{#input:type=submit|value=Categorise!}}

	{{#input:type=submit|value=Remove|onClick = document.getElementById('setcat-content').setAttribute('value','');}}
}}

[[Category:]] [[Category:]] [[Category:]] [[Category:]] [[Category:]]