Difference between revisions of "Template:Set Template Parameter"

From FollowTheScore
Jump to: navigation, search
(Replacing page with 'x')
Line 1: Line 1:
{{#dpl:execandexit=<!--
+
x
-->²{#vardefine: page ¦ {%DPL_arg1:?%}  }²<!--
 
-->²{#vardefine: tpl  ¦ {%DPL_arg2:t%}  }²<!--
 
-->²{#vardefine: parm ¦ {%DPL_arg3:p%}  }²<!--
 
-->²{#vardefine: val  ¦ {%DPL_arg4:v%}  }²<!--
 
-->²{#vardefine: exec ¦ {%DPL_arg5:no%} }²
 
}}
 
{{#ifeq:{{#var:page}}|?|
 
call this page to change the value of a template parameter in a given page. Change will only be made if the last parameter (DPL_arg5) is set to 'yes'. Otherwise you will see waht would be done.
 
 
 
&DPL_arg1 = page = {{#var:page}}
 
&DPL_arg2 = tpl  = {{#var:tpl}}
 
&DPL_arg3 = parm = {{#var:parm}}
 
&DPL_arg4 = val  = {{#var:val}}
 
&DPL_arg5 = exec = {{#var:exec}}    set to    yes  to perform the update
 
 
 
Use at your own risk - in strange cases templates or parameters may not be detected and changed.
 
 
 
Example:
 
 
 
  ..../index.html?title={{FULLPAGENAME}}&DPL_arg1=MyPage&DPL_arg2=MyTemplate&DPL_arg3=Some Parameter&DPL_arg4=The new value
 
 
 
}}
 
{{#dpl:
 
| execandexit = {{#ifeq:{{#var:page}}|?|&nbsp;|}}
 
| title      = {{#var:page}}
 
| include    = *
 
| updaterules =
 
replace  ~([\{][\{]\s*{{#var:tpl}}\s*.*\¦\s*{{#var:parm}}\s*=\s*?)[^\¦\}]*(\s*[\¦\}])~Us;
 
by        \1{{#var:val}}\2;
 
summary  STV: set value of parameter '{{#var:parm}}' to '{{#var:val}}' in call of template '{{#var:tpl}}';
 
{{#ifeq:{{#var:exec}}|yes|exec;|}}
 
}}
 

Revision as of 08:59, 25 June 2009

x