How can I prevent FCKeditor (Rich Editor) removing variables in a table?
If I have a simple table on a MediaWiki page like this:
{|{{#vardefine:new|style="background: none repeat scroll 0% 0% gold;"}}
|- {{#var:new}}
| hi
|}
and I press Rich Editor to switch to FCKeditor, the table code will change to:
{|
|-
| hi
|}
(So #vardefine and #var are removed!)
I have the VariablesExtension installed.
How can I prevent this? I'm posting it here (SO) because I assume this is a problem which can be fixed using different code on the page. Note开发者_StackOverflow中文版 that if the code is not in a table, there is no problem.
Note: if there are no variables in the table, there is also no problem:
{|style="background: none repeat scroll 0% 0% gold;"
|-
| no variable
|}
I found the solution but it is a bit of a monster. You need to create a template and use it in the table. In this example, the third (and final) parameter defines the colour of the cells (previously defined by a variable in the table - now that variable has been moved to the template).
The template will look like this:
<!-- Get color for this row
-->{{#switch: {{{3|new}}}|
| New
| new
| n = {{#vardefine:color|bgcolor=lightsalmon{{!}}}}
| Open
| open
| o = {{#vardefine:color|bgcolor=khaki{{!}}}}
| Closed
| closed
| c = {{#vardefine:color|bgcolor=lightgreen{{!}}}}
| #default = {{#vardefine:color|bgcolor=gold{{!}}}}
}}<!-- Add color for each cell in the row -->
|-
| {{#var:color}}{{{1|parameter 1}}}
| {{#var:color}}{{{2|parameter 2}}} }}
The table will look like this:
{{template_name|parameter 1|parameter 2|parameter 3}}
{{template_name|parameter 1|parameter 2|parameter 3}}
{{template_name|parameter 1|parameter 2|parameter 3}}
精彩评论