Ajuda:Palavras mágicas
![]() |
Esta página ou secção está a ser traduzida. Ajude e colabore com a tradução. |
Ajuda |
Introdução |
---|
Edição básica |
Formatação avançada |
Predefinições |
Colaboração |
Portal da comunidade |
Palavras mágicas são seqüências de texto que a MediaWiki associa com um valor de retorno ou uma função, tal como o tempo, os detalhes do site, ou página de nomes. Esta página é sobre o uso de palavras mágicas padrão; para uma referência técnica, ver Manual:Magic words.
Existem três tipos gerais de palavras mágicas:
- Interruptores de comportamento: estas são palavras em maiúsculas rodeadas por sublinhados duplos, por exemplo __FOO__
- Variáveis: estas são palavras em maiúsculas cercadas por chaves duplas, por exemplo {{FOO}}. Como tal, elas se parecem muito com predefinições
- Funções de análise sintática: estas precisam de parâmetros e ou são da forma {{foo:...}} ou da forma {{#foo:...}}.
Palavras mágicas dependentes de Página vão afetar ou retornar dados sobre a página atual, mesmo se a palavra é adicionada através de um modelo transcluído ou uma mensagem de sistema incluída.
Interruptores de comportamento
Um interruptor de comportamento controla o layout da página. Eles são escritos como uma palavra mágica envolta com duplo sublinhado.
Palavra | Descrição | Versões |
---|---|---|
Tabela de conteúdos (Índice analítico) | ||
__NOTOC__ | Esconde a tabela de conteúdos (TOC). | |
__FORCETOC__ | Força a tabela de conteúdos a aparecer na sua posição normal (acima do primeiro cabeçalho). | |
__TOC__ | Coloca a tabela de conteúdos na posição atual da palavra (sobrescrevendo __NOTOC__). Se este for usado várias vezes, a tabela de conteúdo será exibida na posição da primeira palavra. | |
Editando | ||
__NOEDITSECTION__ | Esconde a seção editar links ao lado dos títulos (cabeçalhos). | |
__NEWSECTIONLINK__ | Adiciona um link ao lado da guia "Editar" para adicionar uma nova seção em uma página não-discussão. | 1.7+ |
__NONEWSECTIONLINK__ | Remove o link ao lado do guia "Editar" em páginas de discussão de espaços de nomes. | 1.15+ |
Categorias | ||
__NOGALLERY__ | Usado em uma página de categoria, substitui as miniaturas na visualização da categoria com ligações normais. | 1.7+ |
__HIDDENCAT__ | Usado em uma página de categoria, esconde a categoria a partir das listas de categorias em seus membros e categorias pai (há uma opção nas preferências de usuário para mostrar elas). | 1.13+ |
Conversão da língua | ||
__NOCONTENTCONVERT__ __NOCC__ |
Em wikis com variantes da língua, não realiza nenhuma conversão de conteúdo de linguagem (caracteres e frases) no artigo exibido, por exemplo, apenas mostrar chinês (zh) em vez das variantes como zh_cn, zh_tw, zh_sg, or zh_hk. | |
__NOTITLECONVERT__ __NOTC__ |
Em wikis com variantes da língua, não executa a conversão de linguagem sobre o título (todos os outros conteúdos são convertidos). | |
Outros | ||
__END__ | Explicitamente marca a extremidade do artigo, para impedir a MediaWiki de remover os espaços em branco à direita (não parece funcionar mais). | |
__START__ | Sem efeito. | |
__INDEX__ | Diz aos motores de busca para indexar a página (sobreecrever $wgArticleRobotPolicies, mas não robots.txt). | 1.14+ |
__NOINDEX__ | TDiz aos motores de busca para não indexar a página (ie, não listar nos resultados de motores de busca). | 1.14+ |
__STATICREDIRECT__ | Em páginas de redirecionamento, não permite a MediaWiki atualizar automaticamente o link quando alguém move uma página e seleciona "Update any redirects that point to the original title". | 1.13+ |
Variáveis
Variáveis retornam informações sobre a página atual, a wiki, ou data. Sua sintaxe é semelhante à predefinições. Se um nome de predefinição entra em conflito com uma variável, a variável será usada (logo para transcluir a predefinição Predefinição:PAGENAME você precisaria escrever {{Predefinição:PAGENAME}}
). Em alguns casos, adicionando parâmetros irá forçar o analisador a tratar uma variável como uma predefinição; por exemplo, {{CURRENTDAYNAME|x}}
transclui Predefinição:CURRENTDAYNAME.
As variáveis destacadas em laranja são consideradas 'caras', e o número que pode ser incluído em uma página é limitado.
Data & hora
As seguintes variáveis retornam a data atual e o horário de acordo com o fuso horário do usuário preferências, por default se usa o fuso horário UTC.
Devido ao MediaWiki e ao cache do navegador, essas variáveis apresentam freqüentemente da data de quando a página foi gravada no cache em vez de a hora atual.
Variável | Saída | Descrição | Versões |
---|---|---|---|
Ano | |||
{{CURRENTYEAR}} | 2025 | Ano | |
Mês | |||
{{CURRENTMONTH}} | 09 | Mês (completado com zeros à esquerda) | |
{{CURRENTMONTHNAME}} | setembro | Mês(nome) | |
{{CURRENTMONTHNAMEGEN}} | setembro | Mês (forma genitiva) | |
{{CURRENTMONTHABBREV}} | set. | Mês (abreviação) | 1.5+ |
Dia | |||
{{CURRENTDAY}} | 5 | Dia do mês (não completado com zeros) | |
{{CURRENTDAY2}} | 05 | Dia do mês (completado com zeros) | 1.6+ |
{{CURRENTDOW}} | 5 | Dia da semana (não completado com zeros) | |
{{CURRENTDAYNAME}} | sexta-feira | Dia da semana (nome) | |
Tempo | |||
{{CURRENTTIME}} | 17h24min | Tempo (formato de 24 horas HH:mm) | |
{{CURRENTHOUR}} | 17 | Tempo (formato de 24 horas completado com zeros à esquerda) | |
Outros | |||
{{CURRENTWEEK}} | 36 | Semana (número) | |
{{CURRENTTIMESTAMP}} | 20250905172446 | YYYYMMDDHHmmss timestamp | 1.7+ |
As seguintes variáveis fazem o mesmo que as acima, mas utilizando o fuso local do sítio em vez das preferências do utilizador e da UTC:
- {{LOCALYEAR}}
- {{LOCALMONTH}}
- {{LOCALMONTHNAME}}
- {{LOCALMONTHNAMEGEN}}
- {{LOCALMONTHABBREV}}
- {{LOCALDAY}}
- {{LOCALDAY2}}
- {{LOCALDOW}}
- {{LOCALDAYNAME}}
- {{LOCALTIME}}
- {{LOCALHOUR}}
- {{LOCALWEEK}}
- {{LOCALTIMESTAMP}}
- Para uma formatação de tempo mais completa, você pode querer instalar as Extension:ParserFunctions para usar a #time: parser function
Metadados técnicos
Variáveis de revisão retornar dados sobre a edição mais recente da página atual, mesmo vendo uma versão antiga da página.
Variável | Saída | Descrição | Versões |
---|---|---|---|
Site | |||
{{SITENAME}} | CriaçãoWiki | Nome da wiki ($wgSitename) | |
{{SERVER}} | http://creationwiki.org | URL do domínio ($wgServer) | |
{{SERVERNAME}} | creationwiki.org | Nome do domínio ($wgServerName) | |
{{DIRMARK}} {{DIRECTIONMARK}} |
|
Produz uma marca unicode-direcional que corresponde a direção do idioma padrão do wiki (‎ on left-to-right wikis, ‏ on right-to-left wikis), útil em textos com texto multi-direcional.
|
1.7+ |
{{SCRIPTPATH}} | /pt | caminho do script relativo ($wgScriptPath) | |
{{CURRENTVERSION}} | 1.35.14 (bc028c2) | A versão da MediaWiki da wiki. | 1.7+ |
{{CONTENTLANGUAGE}} | pt | Idioma da interface padrão ($wgLanguageCode) | 1.7+ |
Revisão mais recente para a página atual | |||
{{REVISIONID}} | 13335 | ID Único | 1.5+ |
{{REVISIONDAY}} | 24 | Dia em que a edição foi feita (número sem enchimento adicional) | 1.8+ |
{{REVISIONDAY2}} | 24 | Dia em que a edição foi feita (número com enchimento de zeros) | 1.8+ |
{{REVISIONMONTH}} | 08 | Mês em que a edição foi feita (número sem enchimento adicional) | 1.8+ |
{{REVISIONYEAR}} | 2013 | Ano em que a edição foi feita | 1.8+ |
{{REVISIONTIMESTAMP}} | 20130824171240 | Timestamp de quando a edição foi feita | 1.8+ |
{{REVISIONUSER}} | Luiz Alexandre Silva | O nome do usuário que fez a edição mais recente da página. | 1.15+ |
{{PAGESIZE:nome da página}} | 27 678 | Retorna o tamanho em bytes da página especificada. | 1.13+ |
{{PROTECTIONLEVEL:ação}} | protection level | Exibe o nível de proteção (por exemplo 'autoconfirm', 'sysop') para uma dada ação (por exemplo 'edit', 'move') na página atual ou uma string vazia se não estiver protegida. | 1.15+ |
Affects page content | |||
{{DISPLAYTITLE:title}} | Format the current page's title header. The value must be equivalent to the default title: only capitalization changes and replacing spaces with underscores. It can be disabled or enabled by $wgAllowDisplayTitle; disabled by default before 1.10+, enabled by default thereafter. | 1.7+ | |
{{DEFAULTSORT:sortkey}} | Used on a categorized page, sets a default category sort key. | 1.10+ |
Statistics
Numbers returned by these variables normally contain separators (commas or spaces, depending on the local language), but can return raw numbers with the ":R" flag (for example, {{NUMBEROFPAGES}}
→ 4 694 and {{NUMBEROFPAGES:R}}
→ 4694). Use "|R" for magic words that require a parameter like PAGESINCATEGORY (for example {{PAGESINCATEGORY:Help}}
and {{PAGESINCATEGORY:Help|R}}
).
Variable | Output | Description | Versions |
---|---|---|---|
Entire wiki | |||
{{NUMBEROFPAGES}} | 4 694 | Number of wiki pages. | 1.7+ |
{{NUMBEROFARTICLES}} | 1 800 | Number of pages in main namespace. | |
{{NUMBEROFFILES}} | 0 | Number of uploaded files. | 1.5+ |
{{NUMBEROFEDITS}} | 32 837 | Number of page edits. | 1.10+ |
{{NUMBEROFVIEWS}} | Predefinição:NUMBEROFVIEWS | Number of page views. Usually useless on a wiki using caching. | 1.14+ |
{{NUMBEROFUSERS}} | 43 | Number of registered users. | 1.7+ |
{{NUMBEROFADMINS}} | 10 | Number of users in the sysop group. | 1.7+ |
{{NUMBEROFACTIVEUSERS}} | 2 | Number of active users, based on the criteria used in Special:Statistics. | 1.15+ |
{{PAGESINCATEGORY:categoryname}} {{PAGESINCAT:Help}} |
0 0 |
Number of pages in the given category (replace "Help" with the relevant category name). | 1.13+ |
{{NUMBERINGROUP:groupname}} | 4 ({{NUMBERINGROUP:bureaucrat}} used here) |
Number of users in a specific group. | 1.14+ |
{{PAGESINNS:index}} {{PAGESINNAMESPACE:index}} |
not enabled | Number of pages in the given namespace (replace 2 with the relevant namespace index). E.g. {{PAGESINNAMESPACE:14}} equals the number of categories. Disabled by default, enable with $wgAllowSlowParserFunctions. | 1.7+ |
Page names
Variable | Output | Description | Versions |
---|---|---|---|
{{FULLPAGENAME}} | Ajuda:Palavras mágicas | Namespace and page title. | 1.6+ |
{{PAGENAME}} | Palavras mágicas | Page title. | |
{{BASEPAGENAME}} | Palavras mágicas | Page title excluding the current subpage and namespace ("Title" on "Title/foo"). | 1.7+ |
{{SUBPAGENAME}} | Palavras mágicas | The subpage title ("foo" on "Title/foo"). | 1.6+ |
{{SUBJECTPAGENAME}} | Ajuda:Palavras mágicas | The namespace and title of the associated content page. | 1.7+ |
{{TALKPAGENAME}} | Ajuda Discussão:Palavras mágicas | The namespace and title of the associated talk page. | 1.7+ |
The following are URL-encoded equivalents:
- {{FULLPAGENAMEE}}
- {{PAGENAMEE}}
- {{BASEPAGENAMEE}}
- {{SUBPAGENAMEE}}
- {{SUBJECTPAGENAMEE}}
- {{TALKPAGENAMEE}}
As of 1.15+, these can all take a parameter, allowing specification of the page to be operated on, instead of just the current page:
- {{PAGENAME:Template:Main Page}} -> Main Page
Namespaces
Variable | Output | Description | Versions |
---|---|---|---|
{{NAMESPACE}} | Ajuda | Namespace (name) | |
{{SUBJECTSPACE}} {{ARTICLESPACE}} |
Ajuda Ajuda |
Name of the associated content namespace | 1.7+ |
{{TALKSPACE}} | Ajuda Discussão | Name of the associated talk namespace | 1.7+ |
The following are URL-encoded equivalents:
- {{NAMESPACEE}}
- {{SUBJECTSPACEE}}
- {{TALKSPACEE}}
As of 1.15+, these can all take a parameter, specifying the property should be returned for a given title instead of the current page:
- {{NAMESPACE:Template:Main Page}} -> Predefinição
Funções de análise sintática
Parser functions are very similar to variables, but take one or more parameters (technically, any magic word that takes a parameter is a parser function), and the name is usually prefixed with a hash to distingush them from possible templates)
This page only describes parser functions that are integral to the MediaWiki software. Other parser functions may be added by MediaWiki extensions such as the ParserFunctions extension.
URL data
Variable | Output | Description | Versions |
---|---|---|---|
{{localurl:page name}} {{localurl:page name|query string}} |
/pt/Page_name /pt/index.php?title=Page_name&query string |
The relative path to the title. | |
{{fullurl:page name}} {{fullurl:page name|query_string}} {{fullurl:interwiki:remote page name|query_string}} |
http://creationwiki.org/pt/Page_name http://creationwiki.org/pt/index.php?title=Page_name&query_string |
The absolute path to the title. This will also resolve Interwiki prefixes. | 1.5+ |
{{filepath:file name}} {{filepath:file name|nowiki}} |
https://creationwiki.org/pool/images/b/bc/Wiki.png https://creationwiki.org/pool/images/b/bc/Wiki.png |
The absolute URL to a media file. | 1.12+ |
{{urlencode:string}} | x+y+z
|
The input encoded for use in URLs. | 1.7+ |
{{anchorencode:string}} | x_y_z
|
The input encoded for use in URL section anchors (after the '#' symbol in a URL). | 1.8+ |
Namespaces
{{ns:}}
returns the localized name for the namespace with that index.
Content namespaces | Talk namespaces | |||
---|---|---|---|---|
Usage | Output | Usage | Output | |
{{ns:-2}} or {{ns:Media}} | Multimédia | {{ns:-1}} or {{ns:Special}} | Especial | |
{{ns:0}} | {{ns:1}} or {{ns:Talk}} | Discussão | ||
{{ns:2}} or {{ns:User}} | Utilizador | {{ns:3}} or {{ns:User talk}} | Utilizador Discussão | |
{{ns:4}} or {{ns:Project}} | CriaçãoWiki | {{ns:5}} or {{ns:Project talk}} | CriaçãoWiki Discussão | |
{{ns:6}} or {{ns:File}} or {{ns:Image}} | Ficheiro | {{ns:7}} or {{ns:File talk}} or {{ns:Image talk}} | Ficheiro Discussão | |
{{ns:8}} or {{ns:MediaWiki}} | MediaWiki | {{ns:9}} or {{ns:MediaWiki talk}} | MediaWiki Discussão | |
{{ns:10}} or {{ns:Template}} | Predefinição | {{ns:11}} or {{ns:Template talk}} | Predefinição Discussão | |
{{ns:12}} or {{ns:Help}} | Ajuda | {{ns:13}} or {{ns:Help talk}} | Ajuda Discussão | |
{{ns:14}} or {{ns:Category}} | Categoria | {{ns:15}} or {{ns:Category talk}} | Categoria Discussão |
Formatting
Usage | Output | Description | Version |
---|---|---|---|
{{lc:string}} | text transform | The lowercase input. | 1.5+ |
{{lcfirst:string}} | teXt tRaNsFoRm | The input with the first character lowercase. | 1.5+ |
{{uc:string}} | TEXT TRANSFORM | The uppercase input. | 1.5+ |
{{ucfirst:string}} | TeXt tRaNsFoRm | The input with the first character uppercase. | 1.5+ |
{{formatnum:unformatted number}} {{formatnum:formatted number|R}} |
-987 654 321,654321 -987.654.321.654321 |
The input with decimal and decimal group separators, and localized digit script, according to the wiki's default locale. the |R parameter can be used to unformat a number, for use in mathmatical situations. | 1.7+ 1.13+ |
{{#formatdate:date}} {{#formatdate:date|format}} |
May 10, 2001 May 10, 2001 |
Formats an unlinked date based on user 'Date format' preference. For logged-out users and those who have not set a date format in their preferences, dates can be given a default: default (site default), mdy , dmy , ymd , ISO 8601 . NOTE: Although the ISO 8601 standard requires that dates be in the Gregorian calendar, the ISO parameter in this function will still format dates that fall outside the usual Gregorian range (eg dates prior to 1583). |
1.15+ |
{{padleft:xyz|number}} {{padleft:xyz|number|separator}} |
00xyz __xyz |
Inserts a string of padding characters (character chosen in third parameter; default '0') of a specified length (second parameter) next to a chosen base character or variable (first parameter). The final digits or characters in the base replace the final characters in the padding; ie. {{padleft:44|3|0}} produces 044. bug (fixed in r45734): multibyte characters are interpreted as two characters, which can skew width. These also cannot be used as padding characters. |
1.8+ |
{{padright:xyz|number}} {{padright:xyz|number|separator}} |
xyz00 xyz__ |
Identical to padleft, but adds padding characters to the right side. | |
{{plural:2|is|are}} | are | Outputs the correct given pluralization form (parameters except first) depending on the count (first parameter). Plural transformations are used for languages like Russian based on "count mod 10". | |
{{grammar:N|noun}} | noun |
Outputs the correct inflected form of the given word described by the inflection code after the colon (language-dependent). Grammar transformations are used for inflected languages like Polish. See also Manual:$wgGrammarForms. |
1.7+ |
Miscellaneous
Usage | Output | Description | Version |
---|---|---|---|
{{int:message name}} {{int:edit}} |
Editar (depends on user language, try: fr •ja) |
Internationalizes (translates) the given interface (MediaWiki namespace) message into the user language. Note that this can damage/confuse cache consistency, see bug 14404. | |
{{#language:language code}} {{#language:ar}} {{#language:th}} |
language code العربية ไทย |
The native name for the given language code. | 1.7+ |
{{#special:special page name}} {{#special:Special:UserLogin}} |
Especial:Special page name Especial:Entrar |
The localized name for the given canonical Special: page. | 1.9+ |
{{#tag:tagname}} {{#tag:tagname |tag content |parameter=value |parameter2=value }} |
(depends on parser tag) | Alias for XML-style parser or extension tags, but parsing wiki code. Attribute values can be passed as parameter values ('<tagname attribute="value"> ' → '{{#tag:tagname|attribute=value}} '), and inner content as an unnamed parameter ('<tagname>content</tagname> ' → '{{#tag:tagname|content}} ').
|
1.12+ |
{{GENDER:username |return text if user is male |return text if user is female |return text if user hasn't defined their gender}} |
(depends on the named user's gender) | A switch for the gender set in Special:Preferences | 1.15+ |