User:Adaz: Difference between revisions

Jump to navigation Jump to search
300 bytes added ,  12 November 2022
m
no edit summary
(Translation of section create finidhed)
mNo edit summary
Line 93: Line 93:


== Modification d'un modèle==
== Modification d'un modèle==
Editing a template is often as easy as editing a normal wiki page. Lets say you want to edit a template with the name ''what you always wanted to know''. Either search for the template using the template namespace like ''Template:What you always wanted to know'' or click on a link to get you there.
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.


If the template code is very complex, it might be an idea to resist tampering with it, even though the edits can easily be undone.
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.


Always try to add documentation to templates missing that, preferably using {{tl|informative template}}.
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>


===Passing unnamed parameters===
Son utilisation :
Passing parameters to templates make them a lot more useful. Unnamed parameters can be used in the order they are passed, in essence <tt><nowiki>{{{1}}}</nowiki></tt>, <tt><nowiki>{{{2}}}</nowiki></tt> etc.  Consider the following template, ''Template:Hello'':
  <nowiki>{{</nowiki>'''hello'''|''titre''<nowiki>|</nowiki>''nom''<nowiki>}}</nowiki>
<pre>Hello, {{{1|}}}{{{2|stranger}}}!</pre>


Its usage:
Les deux paramètres sont facultatifs . Voici des exemples d'utilisation :
<nowiki>{{</nowiki>'''hello'''<nowiki>|</nowiki>''title''<nowiki>|</nowiki>''name''<nowiki>}}</nowiki>


And an example:
  <pre>{{hello|Dr.|Falken}}
  <pre>{{hello|Dr.|Falken}}</pre>
{{hello||}}
Hello, Dr. Falken!
</pre>
Résultats
<pre>Hello, Dr. Falken!
Hello stranger!
</pre>


===Default values===
===Les valeurs par défaut ===
You might wonder what that vertical stroke and the text following, <tt><nowiki>{{{</nowiki>1'''|'''<nowiki>}}}{{{</nowiki>2'''|stranger'''<nowiki>}}}</nowiki></tt>, in ''Template:Hello'' does. Most of you will already have guessed that they are default values.  Having at least an ''empty'' default value is a good practice, as templates otherwise will break when passed an empty parameter. Here is what happens when the above template is used without parameters:
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!
And here is what would happen if it would be used without parameters and did not have default values:
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>


===Passing named parameters===
===Passer des paramètres nommés===
While using a template with named parameters can be a bit more of typing, they are not that much extra typing when editing a template. They are however practical some other ways, they can be passed to a template in any order and, more important, they are named (as in not numbered). That last thing makes them immensely more useful in complex templates.
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.


Using them in a template are not that different than unnamed parameters. Using the above template, but with named parameters, we could instead type:
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>


Its usage:
Son utilisation :
  <nowiki>{{</nowiki>'''hello''' <nowiki>|</nowiki>''title='' <nowiki>|</nowiki>''name=''<nowiki>}}</nowiki>
  <nowiki>{{</nowiki>'''hello''' <nowiki>|</nowiki>''title='' <nowiki>|</nowiki>''name=''<nowiki>}}</nowiki>


And an example:
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=
  {{Informative template|1=
__NOTOC__
  __NOTOC__
== Goal ==
  == Goal ==
This template can be used to show a friendly hello.
  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]].
  Adding this template to a page will automatically add that page to [[:Category:Pages that says hello]].
 
== Usage ==
  == Usage ==
  &lt;nowiki&gt;{{&lt;/nowiki&gt;'''hello'''&lt;nowiki&gt;|&lt;/nowiki&gt;''title''&lt;nowiki&gt;|&lt;/nowiki&gt;''name''&lt;nowiki&gt;}}&lt;/nowiki&gt;
  &lt;nowiki&gt;{{&lt;/nowiki&gt;'''hello'''&lt;nowiki&gt;|&lt;/nowiki&gt;''title''&lt;nowiki&gt;|&lt;/nowiki&gt;''name''&lt;nowiki&gt;}}&lt;/nowiki&gt;
 
;parameter:  Optional title, for example "<tt>Dr.</tt>"
  ;parameter:  Optional title, for example "<tt>Dr.</tt>"
 
;parameter:  Optional name, defaults to "<tt>stranger</tt>"
  ;parameter:  Optional name, defaults to "<tt>stranger</tt>"
 
== Examples ==
  == Examples ==
  <pre>{{hello|Dr.|Falken}}</pre>
  <pre>{{hello|Dr.|Falken}}</pre>
Hello, Dr. Falken!
  Hello, Dr. Falken!
 
  <pre>{{hello}}</pre>
  <pre>{{hello}}</pre>
Hello, stranger!
  Hello, stranger!
 
}}
  }}
 
[[Category:Hello templates]]
  [[Category:Hello templates]]
</noinclude></nowiki>
  </noinclude></nowiki>


===Category suppression===
===Category suppression===
Line 177: Line 181:


  <nowiki>
  <nowiki>
...
  ...
}}
  }}
 
{{main other|[[Category:Hello templates]]}}
  {{main other|[[Category:Hello templates]]}}
</noinclude></nowiki>
  </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 =  <!-- English -->
en
  en
| de =  <!-- German -->
  | de =  <!-- German -->
de
  de
| fr =  <!-- French -->
  | fr =  <!-- French -->
fr
  fr
}}.wikipedia.org Wikipedia]</nowiki>
  }}.wikipedia.org Wikipedia]</nowiki>


  <nowiki>{{LangSwitch
  <nowiki>{{LangSwitch
| en =  <!-- English -->
  | en =  <!-- English -->
{{ The template with English contents }}
  {{ The template with English contents }}
| de =  <!-- German -->
  | de =  <!-- German -->
{{ The template with German contents }}
  {{ The template with German contents }}
| fr =  <!-- French -->
  | fr =  <!-- French -->
{{ The template with French contents }}
  {{ The template with French contents }}
}}</nowiki>
  }}</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>
  | 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>&lt;!-- Comment --&gt;</tt>) will help a lot.   
A good hint on getting more readable template source is that well placed HTML comments (<tt>&lt;!-- Comment --&gt;</tt>) will help a lot.   
Line 238: Line 242:


===Advanced template help===
===Advanced template help===
*[http://meta.wikimedia.org/wiki/Meta:About_Meta Mediawiki Meta]
*[[meta:Meta:About_Meta|Mediawiki Meta]]
**[http://meta.wikimedia.org/wiki/Help:Template Meta:Help:Template]
**[[meta:Help:Template|Meta:Help:Template]]
**[http://meta.wikimedia.org/wiki/Help:Advanced_templates Meta:Help:Advanced templates]
**[[meta:Help:Advanced_templates|Meta:Help:Advanced templates]]
**[http://meta.wikimedia.org/wiki/Help:Table Meta:Help:Table]
**[[meta:Help:Table|Meta:Help:Table]]
*{{mediawiki|Project:About}}
*{{mediawiki|Project:About}}
**{{mediawiki|Help:Tables}}
**{{mediawiki|Help:Tables}}
482

edits

Navigation menu