我刚刚安装了 Mediawiki 并意识到为新手配置它非常复杂。
作为我的第一个条目,我想更改字体颜色:
{{ font color | green | green text }}
为此,我从 Wikipedia Special:Export 页面导入了 Template:Font color
,但仍然没有得到彩色文本,但是:
{{ safesubst:#if:
| {{ safesubst:#if:
| {{ safesubst:#ifeq: | yes
| [[ {{ safesubst:#if:1| }}|{{ safesubst:#if:1| }}]]
| [[|{{ safesubst:#if:1| }}]]
}}
| {{ safesubst:#if:1| }}
}}
| {{ safesubst:#if:
| {{ safesubst:#ifeq: | yes
| [[ {{ safesubst:#if:1| green text }} |{{ safesubst:#if:1| green text }}]]
| [[ {{ safesubst:#if:1| }} |{{ safesubst:#if:1| green text }}]]
}}
| {{ safesubst:#if:1| green text }}
}}
}}
你能帮帮我吗?
最佳答案
您最好不要尝试从维基百科导入模板。这些年来它们变得异常复杂,您几乎需要成为 wiki 模板标记方面的专家才能更改任何内容。
相反,我建议您自己制作。它们可以非常简单,并且因为您拥有 wiki,所以您可以轻松添加自己的自定义 CSS。例如,如果您想要不同颜色的文本,您可以执行以下操作。首先,向您的 MediaWiki:Common.css
页面添加一些规则:
.text-color-green {
color: green;
}
.text-color-blue {
color: blue;
}
.text-color-red {
color: red;
}
然后使用以下内容创建Template:Font color
:
<span class="text-color-{{{1}}}">{{{2}}}</span>
然后你可以用{{Font color|green|green text}}
制作绿色文字,用{{Font color|red|red text}}
制作红色文字等
在 CSS 中执行此操作而不是使用内联样式使以后更新样式变得容易,并且浏览器渲染速度应该更快。
更好的方法是使模板语义化。例如,如果您希望在某些内容获得批准时将文本颜色设为绿色,您可以将以下内容添加到 MediaWiki:Common.css
:
.approved {
color: green;
}
然后使用以下内容创建Template:Approved
:
<span class="approved">{{{1}}}</span>
然后你可以通过调用{{Approved|some approved text}}
来制作批准文本。然后,在将来,如果您决定也需要将所有批准的文本加粗,您只需将 font-weight: bold;
添加到 approved
样式和所有内容将被更新。
关于mediawiki - 创建 MediaWiki 模板以设置页面中的字体颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44373809/