MediaWiki Infobox CSS 问题

问题描述 投票:0回答:1

我对 MediaWiki 还很陌生,并且已经进行了基本安装。 我想将此信息框添加到我的维基:

{| cellspacing="1" cellpadding="1" style="float:right; clear:right; margin: 0 0 .5em 1em; width:280px; background: border-collapse:collapse; border:3.5px solid {{{color|}}}; font-size:smaller; line-height:1.5"
|-
|<div>
{| border="0" cellpadding="4" cellspacing="0" style="float:right; margin:0 0 0 0; width:100%; background:; border-collapse:collapse; vertical-align: middle"
|-
! colspan="2" style="text-align:center; color:#FFFFFF; background:#212121; font-size:150%;" | {{{conflict|<font color="white">{{{conflict|}}}</font>}}}
|- style="text-align:center;"
|-
! colspan="2" style="text-align:center; color:#FFFFFF; background:#212121; font-size:100%;" | {{{partof|<font color="white">Part of {{{partof|}}}</font>}}}
|- style="text-align:center;"
|-
{{#if:{{{image<includeonly>|</includeonly>}}} |
{{!}} colspan="2" style="text-align:center;background-color:#;" {{!}}{{{image}}}
{{!}}-
}}
|- 
|- style="border-top: 1px solid #999; border-bottom: 1px solid #999;"
| style="{{#if:{{{date|}}}| |display: none;}}" valign="top" | <font size=2>'''Date'''</font>
| style="{{#if:{{{date|}}}| |display: none;}}" class="infoboxcell" valign="top" | {{{date|}}}
|- style="border-top: 1px solid #999; border-bottom: 1px solid #999;"
| style="{{#if:{{{location|}}}| |display: none;}}" valign="top" | <font size=2>'''Location'''</font>
| style="{{#if:{{{location|}}}| |display: none;}}" class="infoboxcell" valign="top" | {{{location|}}}
|- style="border-top: 1px solid #999; border-bottom: 1px solid #999;"
| style="{{#if:{{{result|}}}| |display: none;}}" valign="top" | <font size=2>'''Result'''</font>
| style="{{#if:{{{result|}}}| |display: none;}}" class="infoboxcell" valign="top" | {{{result|}}}
|- style="border-top: 1px solid #999; border-bottom: 1px solid #999;"
| style="{{#if:{{{status|}}}| |display: none;}}" valign="top" | <font size=2>'''Status'''</font>
| style="{{#if:{{{status|}}}| |display: none;}}" class="infoboxcell" valign="top" | {{{status|}}}
|- style="border-top: 1px solid #999; border-bottom: 1px solid #999;" 
|-
! colspan="2" style="{{#if:{{{hideb|}}}|display: none;| |}} text-align:center; font-weight:normal; color:#FFFFFF; background:#212121;" | '''Belligerents'''
|- style="border-top: 1px solid #999; border-bottom: 1px solid #999;"
| style="{{#if:{{{left_belligerents|}}}| |display: none;}}" valign="top" | {{{left_belligerents|}}}
| style="{{#if:{{{right_belligerents|}}}| |display: none;}}" class="infoboxcell" valign="top" | {{{right_belligerents|}}}
|-
! colspan="2" style="{{#if:{{{hideb|}}}|display: none;| |}} text-align:center; font-weight:normal; color:#FFFFFF; background:#212121;" | '''Commanders and leaders'''
|- style="border-top: 1px solid #999; border-bottom: 1px solid #999;"
| style="{{#if:{{{left_leadership|}}}| |display: none;}}" valign="top" | {{{left_leadership|}}}
| style="{{#if:{{{right_leadership|}}}| |display: none;}}" class="infoboxcell" valign="top" | {{{right_leadership|}}}
|-
! colspan="2" style="{{#if:{{{hideb|}}}|display: none;| |}} text-align:center; font-weight:normal; color:#FFFFFF; background:#212121;" | '''Strength'''
|- style="border-top: 1px solid #999; border-bottom: 1px solid #999;"
| style="{{#if:{{{left_strength|}}}| |display: none;}}" valign="top" | {{{left_strength|}}}
| style="{{#if:{{{right_strength|}}}| |display: none;}}" class="infoboxcell" valign="top" | {{{right_strength|}}}
|-
! colspan="2" style="{{#if:{{{hideb|}}}|display: none;| |}} text-align:center; font-weight:normal; color:#FFFFFF; background:#212121;" | '''Casualties and losses'''
|- style="border-top: 1px solid #999; border-bottom: 1px solid #999;"
| style="{{#if:{{{left_casualties|}}}| |display: none;}}" valign="top" | {{{left_casualties|}}}
| style="{{#if:{{{right_casualties|}}}| |display: none;}}" class="infoboxcell" valign="top" | {{{right_casualties|}}}
|-
<div>
|}
|}
<noinclude>
Example usage:<pre>
{{Infobox conflict
|color=Example
|conflict=Example
|partof=Example
|image=Example
|date=Example
|location=Example
|result=Example
|status=Example
|left_belligerents=Example
|right_belligerents=Example
|left_leadership=Example
|right_leadership=Example
|left_strength=Example
|right_strength=Example
|left_casualties=Example
|right_casualties=Example
}}
</pre>
</noinclude>

但是,由于某种原因,大多数 CSS 都没有被解析。

我已经启用了以下扩展,但仍然不起作用。我尝试在互联网上搜索答案,但没有找到任何东西。

wfLoadExtension ( 'TemplateStyles' );
wfLoadExtension( 'Scribunto' );  
$wgScribuntoDefaultEngine = 'luastandalone';
$wgEnableParserHooks = true;
css mediawiki mediawiki-templates scribunto
1个回答
0
投票
  1. 您需要启用解析器功能才能使用
    {{#if:}}}
  2. 使用 CSS 禁用表格行 (
    display: none
    ) 是不寻常的,我怀疑这是否是最佳实践。我建议您用
    {{#if:}}
    包裹整个表格行,用
    |
    替换
    {{!}}
    并插入
    <nowiki />
    以保证解析器函数参数的开头和结尾不会丢失新行:
{{#if:{{{left_casulaties|}}}|<nowiki />
{{!}}-
{{!}} {{{left_casualties}}}
}}
© www.soinside.com 2019 - 2024. All rights reserved.