Le module
Module:Navigation facilite la création de palette de navigation.
Syntaxe
{{#invoke:Navigation|build
| classes = Classes optionnelles
| titre = Titre optionnel de la palette
| Titre de la première section
| Contenu de la première section
| ...
| Titre de la dernière section
| Contenu de la dernière section
}}
Exemples
Navigation simple
{{#invoke:Navigation|build
| classes = Classes optionnelles
| titre = Titre
| Section #1
| Contenu #1
| Section #2
| Contenu #2
| Section #3
| Contenu #3
}}
Titre |
---|
Section #1
| Contenu #1
|
---|
Section #2
| Contenu #2
|
---|
Section #3
| Contenu #3
|
---|
Section #4
| Contenu #4
|
---|
Nvigations imbriquées
{{#invoke:Navigation|build
| titre = Titre
| Section #1
| {{#invoke:Navigation|build
| Section #1.1
| Contenu #1.1
| Section #1.2
| Contenu #1.2
}}
| Section #2
| {{#invoke:Navigation|build
| titre = Titre imbriquée
| Section #1.1
| Contenu #1.1
| Section #2.2
| Contenu #2.2
}}
| Section #3
| Contenu #3
| Section #4
| Contenu #4
}}
Titre |
---|
Section #1
| Section #1.1
| Contenu #1.1
|
---|
Section #1.2
| Contenu #1.2
|
---|
|
---|
Section #2
| Titre imbriquée |
---|
Section #1.1
| Contenu #1.1
|
---|
Section #2.2
| Contenu #2.2
|
---|
|
---|
Section #3
| Contenu #3
|
---|
Section #4
| Contenu #4
|
---|
local p = {}
function p.build(frame)
local navigation = mw.html.create('table'):addClass('mw-navigation')
if frame.args['classes'] ~= nil and frame.args['classes'] ~= '' then
navigation:addClass(frame.args['classes'])
end
frame.args['classes'] = nil
-- Navigation's title
if frame.args['titre'] ~= nil and frame.args['titre'] ~= '' then
navigation
:tag('tr')
:tag('th')
:addClass('mw-title')
:attr('colspan', '2')
:wikitext(frame.args['titre'])
end
frame.args['titre'] = nil
-- Navigation's body
local section
for index, value in ipairs(frame.args) do
if 1 == index % 2 then
-- Memorize section name
section = value
else
-- Print section name and values
navigation
:tag('tr')
:tag('th'):wikitext(section):done()
:tag('td'):wikitext(value)
end
end
return tostring(navigation)
end
return p