Jump to content
Wikipedia The Free Encyclopedia

Module:Military navigation

From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing.
Page template-protected This module is currently protected from editing.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
Warning This template is used on approximately 67,000 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them.
This module depends on the following other modules:
Regular
Cavalry

The various navigation templates maintained by the Military history WikiProject are all intended to be implemented through a single base template, which combines the project's common template style with the standard navigation box format. This is needed primarily to allow multiple such templates to be stacked together—with each other, or with infobox templates—to present the appearance of a continuous block; it is also beneficial for providing a consistent appearance to the entire set of articles within our scope.

Any military-related navigational template should be created using the {{military navigation }} base template, as shown below:

{{Military navigation
| name = 
| raw_name =
| state = 
| style = 
| title = 
| image = 
| imageleft = 
| odd_color = 
| even_color = 
| above = 
| listclass = 
| group1 = 
| list1 = 
| group2 = 
| list2 = 
| group3 = 
| list3 = 
...
| group30 = 
| list30 = 
| below = 
}}
name
The actual page name (i.e. "XYZ" for Template:XYZ) of the newly-created template.
raw_name
Use instead of "name" to omit the  V · T · E  links from the title bar.
title
The displayed title of the navigation box.
listclass
Optional – but typically hlist, to format content as horizontal lists. In the case of hlists in above or below fields, set bodyclass=hlist, instead.
style
Optional – an alternative style for the template; this may be set to "wide" to produce a full-width box. The alternative style should be used sparingly; it is intended that the majority of navigational templates will use the default style (in the wild, "wide" has become quite common). The above example template formatted with style=wide is shown below:
Regular
Cavalry
state
Optional – may be set to "collapsed" to force the template to render in its closed state by default.
odd_color/even_color
Optional – the stripe colors for alternating listN items to use. These parameters should be used sparingly; in the absence of a good reason to do otherwise, templates should use the default stripe colors.
groupN/listN
The body of the navigation box, consisting of successive horizontal blocks of content (the listN fields) with optional labels (the corresponding groupN fields). Please see the documentation for {{navbox }} for more details on the different layouts possible.
above
Optional – the sub-header of the navigation box; please see the documentation for {{navbox }} for more details on the resulting layout when this is used.
below
Optional – the footer of the navigation box; please see the documentation for {{navbox }} for more details on the resulting layout when this is used.
image
Optional – an image to be displayed at the right of the box, given in the form [[File:Example.jpg|100px]]. This parameter should be used sparingly, and typically only in conjunction with the full-width template style.
imageleft
Optional – an image to be displayed at the left of the box, given in the form [[File:Example.jpg|100px]]. This parameter should be used sparingly, and typically only in conjunction with the full-width template style.

Common problems with navigation templates

There are several known issues with the current navigation template design that editors should be aware of:

Shifted header wrapping
A long header used in a narrow navigation template may wrap incorrectly, with the second line being indented further than necessary. A workaround is possible by adding a <br /> tag between the words where the wrapping is to occur. This should be done to separate link-text to the right of the 'pipe' (|), as follows: [[Article title|Article <br /> title]]. An alternative method is to use {{wrap }} for the link-text as follows: [[A very long article title|{{wrap|A very long article title}}]], which allows the browser to break as-needed.
Stretching or overflowed boxes
A very long header formatted as a single link may cause a template to stretch beyond its normal width, or the whole link to extend off too far to the right. A workaround is possible by breaking the header onto multiple lines, as shown above.
The above documentation is transcluded from Module:Military navigation/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.

 localp={}

 localNavbox=require('Module:Navbox')
 localStyles=require('Module:WPMILHIST Infobox style')

 localfunctionisblank(s)
 return(nots)ors==''
 end
 localfunctionifnotblank(s,p,t)
 return(sands~='')and(p..s)ort
 end

 functionp.main(frame)
 localargs={}
 localpargs=frame:getParent().args
 localfargs=frame.args
 localsargs={}
 localtcats=''

 -- process bodystyle and titlestyle
 localstyle=fargs['style']orpargs['style']or''
 ifstyle=='wide'then
 args['titlestyle']=Styles['nav_box_wide_header']
 args['bodystyle']=Styles['nav_box_wide']
 else
 args['titlestyle']=Styles['nav_box_header']
 localborder=fargs['border']orpargs['border']or''
 ifborder=='child'orborder=='subgroup'then
 args['bodystyle']=Styles['nav_box_child']
 tcats=tcats..'[[Category:Pages using military navigation subgroups without wide style]]'
 else
 args['bodystyle']=Styles['nav_box']
 end
 end
 sargs['titlestyle']=1
 sargs['bodystyle']=1

 -- process groupstyle, abovestyle, belowstyle
 args['groupstyle']=Styles['nav_box_label']..(fargs['groupstyle']orpargs['groupstyle']or'')
 sargs['groupstyle']=1
 args['abovestyle']=Styles['nav_box_label']..(fargs['abovestyle']orpargs['abovestyle']or'')
 sargs['abovestyle']=1
 args['belowstyle']=Styles['nav_box_label']..(fargs['belowstyle']orpargs['belowstyle']or'')
 sargs['belowstyle']=1
 -- process oddstyle, evenstyle
 args['oddstyle']=ifnotblank((fargs['odd_color']orpargs['odd_color']),'background:',nil)
 args['evenstyle']=ifnotblank((fargs['even_color']orpargs['even_color']),'background:',nil)
 sargs['oddstyle']=1
 sargs['evenstyle']=1
 -- process name and rawname
 args['name']=ifnotblank((fargs['name']orpargs['name']),'',(fargs['rawname']orpargs['rawname']))
 ifisblank(args['name'])thenargs['navbar']='plain'end
 sargs['name']=1
 sargs['rawname']=1

 -- copy the remaining args, with frame args overriding parent args
 fork,vinpairs(pargs)do
 ifvandv~=''andsargs[k]==nilthen
 args[k]=v
 end
 end
 fork,vinpairs(fargs)do
 ifvandv~=''andsargs[k]==nilthen
 args[k]=v
 end
 end
 -- add allow wrap
 ifargs['title']andstyle~='wide'then
 ifnotmw.ustring.match(args['title'],'<span class="wrap">')then
 -- probably a more efficient way to match 15 or more characters
 localm='[^%[%]<>|][^%[%]<>|][^%[%]<>|][^%[%]<>|][^%[%]<>|]'
 m=m..m..m
 args['title']=mw.ustring.gsub(args['title'],
 '%[%[('..m..'[^%[%]<>|]*)%]%]',
 '[[%1|<span class="wrap">%1</span>]]')
 args['title']=mw.ustring.gsub(args['title'],
 '%[%[([^%[%]<>|]*)|('..m..'[^%[%]<>|]*)%]%]',
 '[[%1|<span class="wrap">%2</span>]]')
 end
 end

 -- add navbox-vertical for non-wide format
 ifstyle~='wide'then
 args['bodyclass']='navbox-vertical'..(args['bodyclass']and(' '..args['bodyclass'])or'')
 end

 returntcats..Navbox._navbox(args)

 end

 returnp

AltStyle によって変換されたページ (->オリジナル) /