2017-06-05 75 views
2

我剛剛安裝了Mediawiki,意識到爲新手配置它非常複雜。Mediawiki:font color

由於我的第一個項目之一,我想改變字體顏色有:

{{ font color | green | green text }} 

要做到這一點我進口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 }} 
}} 

}} 

你能幫我嗎?

回答

1

MediaWiki吸引剛剛想把維基放在一起的新手。它首先需要大量額外的工作才能獲得體面的,特別是在模板方面。

也許你遺漏了一個擴展名,如ParserFunctionsScribunto?模板使用其他模板,您是否勾選了「包含模板」框?

這是一個有用的博客文章how to import Wikipedia Templates into your own MediaWiki

+1

我之前看到過這篇博客文章,我試圖關注它,但是我忽略的是ParserFunctions擴展。現在我安裝了它,模板運行完美。謝謝! – bLAZ

3

你最好不要試圖從維基百科導入模板。這些年來,他們變得非常複雜,你幾乎需要成爲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樣式中,所有內容都會更新。

+0

謝謝傑克!我會用我創建的模板玩一下。 – bLAZ