482
edits
(Translation of section create finidhed) |
mNo edit summary |
||
| Line 93: | Line 93: | ||
== Modification d'un modèle== | == Modification d'un modèle== | ||
L'édition d'un modèle est aussi simple que l'édition d'une page wiki normale. Disons que vous voulez modifier un modèle avec le nom ''ce que vous avez toujours voulu savoir''. Recherchez le modèle à l'aide du mot-clé '''modèle''' tel que ''Modèle : ce que vous avez toujours voulu savoir'' puis cliquez sur un lien pour vous y rendre. | |||
Si le code du modèle est très complexe, il peut être judicieux de ne pas le modifier sous peine de le corrompre, même si les modifications peuvent facilement être annulées. | |||
Essayez toujours d'ajouter de la documentation aux modèles manquants, de préférence en utilisant {{modèle informatif}}. | |||
===Passer des paramètres sans nom=== | |||
Passer des paramètres aux modèles les rend beaucoup plus utiles. Les paramètres sans nom peuvent être utilisés dans l'ordre dans lequel ils sont passés, essentiellement {{{1}}}, {{{2}}} etc. Considérez le modèle suivant, ''Template:Hello'' : | |||
<pre>Hello, {{{1|}}}{{{2|stranger}}}!</pre> | |||
Son utilisation : | |||
<nowiki>{{</nowiki>'''hello'''|''titre''<nowiki>|</nowiki>''nom''<nowiki>}}</nowiki> | |||
< | |||
Les deux paramètres sont facultatifs . Voici des exemples d'utilisation : | |||
<pre>{{hello|Dr.|Falken}} | |||
<pre>{{hello|Dr.|Falken}}</pre> | {{hello||}} | ||
Hello, Dr. Falken! | </pre> | ||
Résultats | |||
<pre>Hello, Dr. Falken! | |||
Hello stranger! | |||
</pre> | |||
=== | ===Les valeurs par défaut === | ||
Vous vous demandez peut-être ce que fait ce trait vertical et le texte qui suit, ''stranger'', dans ''Template:Hello''. La plupart d'entre vous auront déjà deviné qu'il s'agit de '''valeurs par défaut'''. Avoir au moins une valeur par défaut vide est une bonne pratique, sinon les modèles se plantent lorsqu'un paramètre vide leur est passé. Voici ce qui arrive lorsque le modèle ci-dessus est utilisé sans paramètres : | |||
<pre>{{hello}}</pre> | <pre>{{hello}}</pre> | ||
Hello, stranger! | Il est affiché : | ||
Hello, stranger! | |||
Et voici ce qui se passerait s'il était utilisé sans paramètres et n'avait pas de valeurs par défaut : | |||
<nowiki>Hello, {{{1}}}{{{2}}}!</nowiki> | |||
<nowiki>Hello, {{{1}}}{{{2}}}!</nowiki> | |||
=== | ===Passer des paramètres nommés=== | ||
Bien que l'utilisation d'un modèle avec des paramètres nommés nécessite un peu plus de saisie, ils ne sont pas beaucoup plus complexes lors de la modification. Ils sont réellement très pratiques car ils peuvent être passés à un modèle dans n'importe quel ordre et, plus important encore, ils sont nommés (c'est-à-dire non numérotés). Cette dernière chose les rend immensément plus utiles dans les modèles complexes. | |||
Les utiliser dans un modèle n'est pas si différent des paramètres sans nom. En utilisant le modèle ci-dessus, mais avec des paramètres nommés, nous pourrions plutôt taper :<pre>Hello, {{{title|}}}{{{name|stranger}}}!</pre> | |||
<pre>Hello, {{{title|}}}{{{name|stranger}}}!</pre> | |||
Son utilisation : | |||
<nowiki>{{</nowiki>'''hello''' <nowiki>|</nowiki>''title='' <nowiki>|</nowiki>''name=''<nowiki>}}</nowiki> | <nowiki>{{</nowiki>'''hello''' <nowiki>|</nowiki>''title='' <nowiki>|</nowiki>''name=''<nowiki>}}</nowiki> | ||
En voici un exemple : | |||
<pre>{{hello |title=Dr. |name=Falken}}</pre> | <pre>{{hello |title=Dr. |name=Falken}}</pre> | ||
Hello, Dr. Falken! | Il s’affichee : | ||
Hello, Dr. Falken! | |||
===To include or not include=== | ===To include or not include=== | ||
| Line 140: | Line 144: | ||
<nowiki>Hello, {{{1|}}}{{{2|stranger}}}!<includeonly>[[Category:Pages that says hello]]</includeonly><noinclude> | <nowiki>Hello, {{{1|}}}{{{2|stranger}}}!<includeonly>[[Category:Pages that says hello]]</includeonly><noinclude> | ||
{{Informative template|1= | |||
__NOTOC__ | |||
== Goal == | |||
This template can be used to show a friendly hello. | |||
Adding this template to a page will automatically add that page to [[:Category:Pages that says hello]]. | |||
== Usage == | |||
<nowiki>{{</nowiki>'''hello'''<nowiki>|</nowiki>''title''<nowiki>|</nowiki>''name''<nowiki>}}</nowiki> | |||
;parameter: Optional title, for example "<tt>Dr.</tt>" | |||
;parameter: Optional name, defaults to "<tt>stranger</tt>" | |||
== Examples == | |||
<pre>{{hello|Dr.|Falken}}</pre> | |||
Hello, Dr. Falken! | |||
<pre>{{hello}}</pre> | |||
Hello, stranger! | |||
}} | |||
[[Category:Hello templates]] | |||
</noinclude></nowiki> | |||
===Category suppression=== | ===Category suppression=== | ||
| Line 177: | Line 181: | ||
<nowiki> | <nowiki> | ||
... | |||
}} | |||
{{main other|[[Category:Hello templates]]}} | |||
</noinclude></nowiki> | |||
Apart from '''demospace''' some templates will have a '''nocat''' parameter that when not empty or set as '''nocat = yes''' will suppress categorisation altogether. | Apart from '''demospace''' some templates will have a '''nocat''' parameter that when not empty or set as '''nocat = yes''' will suppress categorisation altogether. | ||
==Traduire un modèle== | == Traduire un modèle== | ||
Templates are translated in a different way than [[Help:Translate|normal articles]]. Instead of creating another page for each translation, all translations are written within one template. To do that one can use the {{tl|LangSwitch}} template, for example like below. | Templates are translated in a different way than [[Help:Translate|normal articles]]. Instead of creating another page for each translation, all translations are written within one template. To do that one can use the {{tl|LangSwitch}} template, for example like below. | ||
<nowiki>[http://{{LangSwitch | <nowiki>[http://{{LangSwitch | ||
| en = <!-- English --> | |||
en | |||
| de = <!-- German --> | |||
de | |||
| fr = <!-- French --> | |||
fr | |||
}}.wikipedia.org Wikipedia]</nowiki> | |||
<nowiki>{{LangSwitch | <nowiki>{{LangSwitch | ||
| en = <!-- English --> | |||
{{ The template with English contents }} | |||
| de = <!-- German --> | |||
{{ The template with German contents }} | |||
| fr = <!-- French --> | |||
{{ The template with French contents }} | |||
}}</nowiki> | |||
{{note|Many templates use tables and have to start from the beginning of the line, like in the above example.}} | {{note|Many templates use tables and have to start from the beginning of the line, like in the above example.}} | ||
| Line 214: | Line 218: | ||
<nowiki>{{LangSwitch | <nowiki>{{LangSwitch | ||
... | |||
| lang = fr }}</nowiki> | |||
==Edition avancée d'un modèle== | == Edition avancée d'un modèle== | ||
The templates can contain some very advanced and often complex code, but even easier code can do great things to make life easier for you as an editor using it later. | The templates can contain some very advanced and often complex code, but even easier code can do great things to make life easier for you as an editor using it later. | ||
While this page will not go into details, there is a few secrets to more advanced templates: | While this page will not go into details, there is a few secrets to more advanced templates: | ||
;Tables:Wiki tables are tricky to understand, but can do a lot for any kind of box template and small layouts. | ; Tables:Wiki tables are tricky to understand, but can do a lot for any kind of box template and small layouts. | ||
;Magic words:Magic words are mostly all uppercase and many of them at first look like templates. Some of them are for example <tt><nowiki>{{CURRENTMONTHNAME}}</nowiki></tt> and <tt><nowiki>__NOTOC__</nowiki></tt>. | ;Magic words:Magic words are mostly all uppercase and many of them at first look like templates. Some of them are for example <tt><nowiki>{{CURRENTMONTHNAME}}</nowiki></tt> and <tt><nowiki>__NOTOC__</nowiki></tt>. | ||
| Line 229: | Line 233: | ||
;HTML:It might seem a bit funny to mention it, but sometimes you forget that you can use (some) html tags in a MediaWiki wiki. | ;HTML:It might seem a bit funny to mention it, but sometimes you forget that you can use (some) html tags in a MediaWiki wiki. | ||
; Cascading style sheets:Like magic words and parser functions can do magic for the functionality of a template CSS can do magic for its appearance. | ;Cascading style sheets:Like magic words and parser functions can do magic for the functionality of a template CSS can do magic for its appearance. | ||
A good hint on getting more readable template source is that well placed HTML comments (<tt><!-- Comment --></tt>) will help a lot. | A good hint on getting more readable template source is that well placed HTML comments (<tt><!-- Comment --></tt>) will help a lot. | ||
| Line 238: | Line 242: | ||
===Advanced template help=== | ===Advanced template help=== | ||
*[ | *[[meta:Meta:About_Meta|Mediawiki Meta]] | ||
**[ | **[[meta:Help:Template|Meta:Help:Template]] | ||
**[ | **[[meta:Help:Advanced_templates|Meta:Help:Advanced templates]] | ||
**[ | **[[meta:Help:Table|Meta:Help:Table]] | ||
*{{mediawiki|Project:About}} | *{{mediawiki|Project:About}} | ||
**{{mediawiki|Help:Tables}} | **{{mediawiki|Help:Tables}} | ||
edits