Page.RemoveTemplateParameter
Make robots for MediaWiki-powered sites!
Brought to you by:
code_driller
New method for Page class that removes a parameter from a template in a wikipage. It is modeled on SetTemplateParameter and reuses much of the same code, but instead of setting a new value for a parameter, the parameter is removed from the page.
Parameters:
templateTitle: template in which to remove a parameter
templateParameter: the parameter to be removed
firstTemplateOnly: if true, only first instance of template, if false all.
If the template or parameter doesn't exist, no action is taken.
C# source, to be inserted in DotNetWikiBot.cs
Thank you. That function can be very useful.
I have one question. Why did you change
site.FormatTemplate(templateTitle, parameters, template);
for
site.FormatTemplate(templateTitle, parameters, false, false, 0);
?
The FormatTemplate change was for my own lazy reasons, I wanted to reformat the templates in the same run. Then I forgot to change it back before submitting it here. Better change it back to the original form site.FormatTemplate(templateTitle, parameters, template) before any general release. Should have no effect on the main function of this Method.
RemoveTemplateParameter(string templateTitle, string templateParameter, bool firstTemplateOnly) method was added in v3