Difference between revisions of "Help:Templates"

From FamiLAB Wiki
Jump to: navigation, search
(Accidentaly I replaced the English version of Help:Templates with the Romanian one. I went back to the history and put the right one. Sorry !)
Line 1: Line 1:
{{PD Help Page/ro}}
+
{{PD Help Page}}
Dacă există formule fixe de text care doriţi să le includeţi în câteva pagini, MediaWiki template este cel mai bun instrument (precum secvenţa de mai sus care este inclusă în paginile din namespaceul de Asistenţă).
+
If you have standard texts you want to include on several pages, the MediaWiki template feature comes into play (like the tag above which is included in the pages of the Help namespace).
  
==Crearea unui template==
+
==Creating a template==
Numele templateurilor sunt prefixate cu <code>Template:</code> şi se pot crea precum oricare altă pagină wiki.
+
Template names are prefixed with <code>Template:</code>, you create them like any other wiki page.
  
==Utilizarea unui template==
+
==Using a template==
Templateurile sunt pagini wiki care pot fi utilizate în cadrul altor pagini în trei moduri diferite:
+
Templates are wiki pages which can be used in other pages in three ways:
:<code><nowiki>{{Nume}}</nowiki></code> ce include conţinutul templateului la momentul afişării paginii <nowiki>"[[Template:Nume]]"</nowiki>.  
+
:<code><nowiki>{{Name}}</nowiki></code> includes the content of the template at the moment the page containing it is fetched <nowiki>"[[Template:Name]]"</nowiki>.  
:<code><nowiki>{{subst:Nume}}</nowiki></code> introduce conţinutul templateului în codul paginii într-o formă editabilă în mod normal <nowiki>"[[Template:Nume]]"</nowiki> după ce textul a fost salvat.  
+
:<code><nowiki>{{subst:Name}}</nowiki></code> inserts the content of the template into the code of the page in a form that is editable normally <nowiki>"[[Template:Name]]"</nowiki> after you have saved your text.  
:<code><nowiki>{{msgnw:Nume}}</nowiki></code> este afişat odată cu pagina iar templateul este într-o formă brută precum sintaxa wiki obţinută prin utilizarea lui <code><nowiki>&lt;nowiki&gt;</nowiki></code>
+
:<code><nowiki>{{msgnw:Name}}</nowiki></code> when the page containing it is fetched, includes the template in a form that displays it as raw wiki syntax, like <code><nowiki>&lt;nowiki&gt;</nowiki></code> does
  
==Utilizatea parametrilor în templateuri ==
+
==Using parameters in templates==
 
<div style="float:right">
 
<div style="float:right">
 
{| {{Prettytable}}  
 
{| {{Prettytable}}  
 
|-
 
|-
|{{Hl2}} colspan="2" align="center" |'''Template cu parametri numerotaţi'''
+
|{{Hl2}} colspan="2" align="center" |'''Template with numbered parameters'''
 
|-
 
|-
 
| colspan="2" |
 
| colspan="2" |
 
<pre><nowiki>  
 
<pre><nowiki>  
'''Un călduros mulţumesc...'''<br>
+
'''A little thank you...'''<br>
<small>cu bine{{{1}}}.<br>
+
<small>for {{{1}}}.<br>
{{{2}}}</small>
+
hugs, {{{2}}}</small>
 
</nowiki></pre>  
 
</nowiki></pre>  
 
|-
 
|-
|{{Hl2}}|'''Introduci'''
+
|{{Hl2}}|'''You type'''
|{{Hl2}}|'''Obţii'''
+
|{{Hl2}}|'''You get'''
 
|-
 
|-
|<code><nowiki>{{Un călduros mulţumesc|cu bine|Vlad}}</nowiki></code>
+
|<code><nowiki>{{Thankyou|all|Joe}}</nowiki></code>
 
|
 
|
{{Thankyou/ro|Vlad}}
+
{{Thankyou|all|Joe}}
 
|-
 
|-
|{{Hl2}} colspan="2" align="center" |'''cu parametri denumiţi'''
+
|{{Hl2}} colspan="2" align="center" |'''with named parameters'''
 
|-
 
|-
 
| colspan="2" |
 
| colspan="2" |
 
<pre><nowiki>  
 
<pre><nowiki>  
'''Un călduros mulţumesc'''<br>
+
'''A little thank you...'''<br>
<small>cu bine{{{reason}}}.<br>
+
<small>for {{{reason}}}.<br>
Vlad{{{signature}}}</small>
+
hugs, {{{signature}}}</small>
 
</nowiki></pre>  
 
</nowiki></pre>  
 
|-
 
|-
|{{Hl2}}|'''Introduci'''
+
|{{Hl2}}|'''You type'''
|{{Hl2}}|'''Obţii'''
+
|{{Hl2}}|'''You get'''
 
|-
 
|-
|<pre><nowiki>{{Un călduros mulţumesc
+
|<pre><nowiki>{{Thankyou
|reason=cu bine
+
|reason=all
|signature=Vlad}}</nowiki></pre>
+
|signature=Joe}}</nowiki></pre>
 
|
 
|
{{Thankyou/ro|Vlad}}
+
{{Thankyou|all|Joe}}
 
|}
 
|}
 
</div>
 
</div>
Pot fi definiţi parametrii în template fie prin enumerare precum <code><nowiki>{{{1}}}</nowiki></code> sau prin denumirea acestora <code><nowiki>{{{param}}}</nowiki></code>.   
+
You can define parameters in templates either numbered as <code><nowiki>{{{1}}}</nowiki></code> or named <code><nowiki>{{{param}}}</nowiki></code>.   
  
'''Exemplu:''' Dacă doriţi să puneţi o notă de mulţumire puteţi să o faceţi introducând-o în pagina de discuţii a utilizatorului. Se va motiva nota şi se va adăuga semnătura. Se poate crea [[Template:Thankyou/ro]] pentru a introduce textul, precum în exemplul din tabel.
+
'''Example:''' You want a little thank you note you can put on the talk page of other users. It will contain a reason and your signature. You could create [[Template:Thankyou]] to enter your text, as in the example in the table.
  
Atunci când este utilizat un template într-un tabel, se introduc valorile parametrilor separate prin caracterul pipe (|): <code><nowiki>{{Thankyou/ro|cu bine|Vlad}}</nowiki></code>. Pentru parametrii denumiţi, folosiţi perechi "nume=valoare" separate prin caracterul pipe:  <code><nowiki>{{Un călduros mulţumesc|reason=cu bine|signature=Vlad}}</nowiki></code>. Avantajul folosirii parametrilor denumiţi este acela al flexibilităţii în ordonare. De asemenea uşurează înţelegerea templateului, în cazul folosirii a mai multor parametri. Dacă doriţi să modificaţi ordinea parametrilor numerotaţi, aceştia trebuie menţionaţi explicit: <code><nowiki>{{Un călduros mulţumesc|2=Vlad|1=cu bine}}</nowiki></code>.
+
When using the template on a page, you fill in the parameter values, separated by a pipe char (|): <code><nowiki>{{Thankyou|all|Joe}}</nowiki></code>. For named parameters use "name=value" pairs separated by a pipe char:  <code><nowiki>{{Thankyou|reason=all|signature=Joe}}</nowiki></code>. The advantage of using named parameters in your template is that they are flexible in order. It also makes the template easier to understand if you have many parameters. If you want to change the order of numbered parameters, you have to mention them explicitly: <code><nowiki>{{Thankyou|2=Joe|1=all}}</nowiki></code>.
  
==Controlul introducerii templateurilor==
+
==Control template inclusion==
Introducerea templateurilor în pagină poate fi controlată prin utilizarea elementelor <code><nowiki><noinclude></nowiki></code> şi a lui <code><nowiki><includeonly></nowiki></code>.
+
You can control template inclusion by the use of <code><nowiki><noinclude></nowiki></code> and
 +
<code><nowiki><includeonly></nowiki></code> tags.
  
Orice altceva între <code><nowiki><noinclude></nowiki></code> şi <code><nowiki></noinclude></nowiki></code> va fi procesat şi afişat doar atunci când pagina este vizualizată în mod direct.
+
Anything between <code><nowiki><noinclude></nowiki></code> and <code><nowiki></noinclude></nowiki></code> will be processed and
 +
displayed only when the page is being viewed directly, not included.
  
Aplicaţii posibile pot fi:
+
Possible applications are:
* Categorisirea templateurilor
+
* Categorising templates
* Linkuri interlinguale către templateurile similare din alte limbi
+
* Interlanguage links to similar templates in other languages
* Texte explicative despre cum se poate folosi un template
+
* Explanatory text about how to use the template
  
Inversarea se face prin <code><nowiki><includeonly></nowiki></code>. Textul dintre <code><nowiki><includeonly></nowiki></code> şi
+
The converse is <code><nowiki><includeonly></nowiki></code>. Text between <code><nowiki><includeonly></nowiki></code> and
<code><nowiki></includeonly></nowiki></code> va fi procesat şi afişat doar atunci când pagina este inclusă. Aplicaţia cea mai uşor de intuit este adăugarea tuturor paginilor care conţin un anumit template la o categorie.
+
<code><nowiki></includeonly></nowiki></code> will be processed and displayed only when the page is
 +
being included. The obvious application is to add all pages containing a given template to a category.
  
Trebuie spus că pot apărea problemele clasice la momentul actualizării -- de exemplu, dacă schimbi categoriile dintr-un template, atunci categoriile paginilor care fac referinţă la acesta nu vor fi actualizate decât dacă acestea sunt editate.
+
Note that the usual update problems apply -- if you change the
==Organizarea templateurilor==
+
categories inside a template, the categories of the referring pages
Pentru ca templaturile să fie eficiente pentru utilizator, acesta trebuie să poată să le găsească şi să le folosească. O tehnică simplă este includerea unui exemplu într-o pagină de template.
+
won't be updated until those pages are edited.
De exemplu:
+
==Organizing templates==
 +
For templates to be effective users need to find them and be able to use them. A simple technique is to include an example on the template page.
 +
For example:
 
<div style="display:table; width:auto;"><pre>
 
<div style="display:table; width:auto;"><pre>
 
<noinclude>
 
<noinclude>
==Utilizare==
+
==Usage==
Permite stabilirea unui link către un anumit subiect:
+
Allows to establish a link to a subject:
{{NumeleTemplateului|Termen1+Termen2+Termen3}}
+
{{NameOfTemplate|Term1+Term2+Term3}}
 
</noinclude>
 
</noinclude>
 
</pre></div>
 
</pre></div>
  
În acest moment, oricare editor poate copia şi pune exemplul într-o pagină similară.
+
Then, an editor can simply copy and paste the example to create a similar page.
  
==Vezi şi==
+
==See Also==
*[[Help:External searches/ro]] -- un exemplu particular de folosire a unui template
+
*[[Help:External searches]] -- a template special use case example
*[[Help:Variables/ro]] -- diferite rafinamente pe care le poţi întâlni în anumite templateuri
+
*[[Help:Variables]] -- fancy stuff you may find in some templates
  
==Linkuri externe==
+
==External links==
 
{{meta|Help:Template}}
 
{{meta|Help:Template}}
  
[[Category:Help/ro|Templates/ro]]
+
[[Category:Help|Templates]]
 
{{Languages|Help:Templates}}
 
{{Languages|Help:Templates}}

Revision as of 08:22, 29 June 2007

Template:PD Help Page If you have standard texts you want to include on several pages, the MediaWiki template feature comes into play (like the tag above which is included in the pages of the Help namespace).

Creating a template

Template names are prefixed with Template:, you create them like any other wiki page.

Using a template

Templates are wiki pages which can be used in other pages in three ways:

{{Name}} includes the content of the template at the moment the page containing it is fetched "[[Template:Name]]".
{{subst:Name}} inserts the content of the template into the code of the page in a form that is editable normally "[[Template:Name]]" after you have saved your text.
{{msgnw:Name}} when the page containing it is fetched, includes the template in a form that displays it as raw wiki syntax, like <nowiki> does

Using parameters in templates

Template:Hl2 colspan="2" align="center" |Template with numbered parameters
 
'''A little thank you...'''<br>
<small>for {{{1}}}.<br>
hugs, {{{2}}}</small>
Template:Hl2|You type Template:Hl2|You get
{{Thankyou|all|Joe}}
Example sunflower image
A little thank you...
for all.
hugs, Joe
Template:Hl2 colspan="2" align="center" |with named parameters
 
'''A little thank you...'''<br>
<small>for {{{reason}}}.<br>
hugs, {{{signature}}}</small>
Template:Hl2|You type Template:Hl2|You get
{{Thankyou
|reason=all
|signature=Joe}}
Example sunflower image
A little thank you...
for all.
hugs, Joe

You can define parameters in templates either numbered as {{{1}}} or named {{{param}}}.

Example: You want a little thank you note you can put on the talk page of other users. It will contain a reason and your signature. You could create Template:Thankyou to enter your text, as in the example in the table.

When using the template on a page, you fill in the parameter values, separated by a pipe char (|): {{Thankyou|all|Joe}}. For named parameters use "name=value" pairs separated by a pipe char: {{Thankyou|reason=all|signature=Joe}}. The advantage of using named parameters in your template is that they are flexible in order. It also makes the template easier to understand if you have many parameters. If you want to change the order of numbered parameters, you have to mention them explicitly: {{Thankyou|2=Joe|1=all}}.

Control template inclusion

You can control template inclusion by the use of <noinclude> and <includeonly> tags.

Anything between <noinclude> and </noinclude> will be processed and displayed only when the page is being viewed directly, not included.

Possible applications are:

  • Categorising templates
  • Interlanguage links to similar templates in other languages
  • Explanatory text about how to use the template

The converse is <includeonly>. Text between <includeonly> and </includeonly> will be processed and displayed only when the page is being included. The obvious application is to add all pages containing a given template to a category.

Note that the usual update problems apply -- if you change the categories inside a template, the categories of the referring pages won't be updated until those pages are edited.

Organizing templates

For templates to be effective users need to find them and be able to use them. A simple technique is to include an example on the template page. For example:

<noinclude>
==Usage==
Allows to establish a link to a subject:
{{NameOfTemplate|Term1+Term2+Term3}}
</noinclude>

Then, an editor can simply copy and paste the example to create a similar page.

See Also

External links

Template:MetaTemplate:Languages