Difference between revisions of "Template:Div col"

From Wiki2
(Created page with "<!----------------------------------------------------------------------------- PLEASE ADD CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE ---------------------------...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<!-----------------------------------------------------------------------------
<includeonly><templatestyles src="Div col/styles.css"/><!--
  PLEASE ADD CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE
--><div class="div-col {{#ifeq:{{{rules|}}}|yes|div-col-rules}} {{{class|}}}" <!--
------------------------------------------------------------------------------>
-->{{#if:{{{colwidth|}}}{{{gap|}}}{{{style|}}}|<!--
{{Documentation subpage}}
-->style="{{#if:{{{colwidth|}}}|column-width: {{{colwidth}}};}}{{#if:{{{gap|}}}|column-gap: {{{gap}}};}}{{#if:{{{style|}}}|{{{style}}}}}"<!--
{{High-risk| 158000+ }}
-->}}><!--
{{Ombox |type=notice |text=Columns are not supported by some older browsers, most notably Internet Explorer 9 and below and Opera 11.0 and below. See [[Template:Reflist#Browser support for columns|this page]] for more information.}}
-->{{#if:{{{content|}}}|{{{content}}}</div>}}<!--
{{CSS3 multiple column layout}}
--></includeonly>{{#invoke:Check for unknown parameters|check|unknown={{main other|[[Category:Pages using div col with unknown parameters|_VALUE_{{PAGENAME}}]]}}|preview=Page using [[Template:Div col]] with unknown parameter "_VALUE_"; use colwidth= to specify column size |ignoreblank=y | colwidth | content | gap | rules| style }}<noinclude>
 
{{Documentation}}
{{tl|Div col}} can be used to make a list into columns that wrap properly and compatibly with portable computer devices, esp. PAD operating systems and small screens. It automatically breaks the available space into equal spaces, meaning, for instance, that it is not necessary to work out the halfway point, or the one-third & two-thirds points between two columns.
</noinclude>
* The list content is either provided by the {{para|content}} parameter (which can be restrictive of what content is allowed; e.g., wiki markup like {{!}} must somehow be escaped), or terminated with {{tl|div col end}}. The {{tl|columns-list}} wrapper uses the parameter method for providing content (including its limitations).
* The template system (family) also offers parameter options to set a smaller (90%) font-size parameter ({{para|small|yes}}), place vertical lines parameter ("rules") between the columns ({{para|rules}}) and to add other custom styling parameter ({{para|style}}).
 
{{tl|Div col}} can create multiple columns in [[web browser]]s which support one of the following [[CSS]] properties:
* ''column-count'' (for [[Cascading Style Sheets#CSS 3|CSS3]]-compliant browsers; see [http://www.w3.org/TR/css3-multicol/ CSS3 module: Multi-column layout])
* ''-moz-column-count'' (for [[Mozilla application framework|Mozilla]]/[[Gecko (layout engine)|Gecko]]-based browsers such as [[Firefox]])
* ''-webkit-column-count'' (for [[WebKit]]-based browsers such as [[Safari (web browser)|Safari]] and [[Google Chrome]])
==Usage==
There are six parameters for this template and their usage is described below.
; {{para|colwidth}} : Specifies the minimum width of the columns and determines automatically the number of columns based on screen width (i.e. more columns will be shown on wider displays). Overrides ''cols''. Can be specified in any CSS unit, for instance in [[Em (typography)|em]], about the width of a capital "M", e.g, <code>colwidth=20em</code>
; {{para|rules}} : Adds vertical lines ("rules") between the columns if set to <code>yes</code> or some CSS styling (e.g. <code>1px dashed blue;</code>).
; {{para|gap}} : Specifies the space between the content of adjacent columns. Specified in any CSS unit, e.g, <code>gap=2em</code>. The default spacing (set by browser) is 1em.
; {{para|style}} : [[Cascading Style Sheets|CSS styling]] to apply to the columns.
; {{para|content}} : content to apply to the columns.
; {{s|{{para|cols}}}} {{nobold|or first unnamed parameter}} : Specifies the number of columns (default 2). ''(Now [[Deprecation|deprecated]],  as ''colwidth'', above, is better suited to flexible formatting for a variety of display screen sizes (from mobile phones, tablets, etc to widescreen cinema-style displays)). For a fixed number of columns, use a template from the [[#See also|See also]] section below.''
 
==Examples==
 
===Usage of "colwidth" parameter===
Important: The usage of the previous parameter "cols" is deprecated. It is strongly recommended to not use now-[[Deprecation|deprecated]] "cols" parameter (please leave it blank) and instead use "colwidth" parameter. 
; Example with column width of 10em
<pre>
{{div col|colwidth=10em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
</pre>
; produces:
{{Div col|colwidth=10em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
 
 
 
===Usage of "rules" parameter===
; Example:
<pre>
{{Div col|rules=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
</pre>
; produces:
{{Div col|rules=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
 
 
===Usage of "gap" parameter===
; Example:
<pre>
{{Div col|colwidth=10em|rules=yes|gap=2em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
</pre>
; produces:
{{Div col|colwidth=10em|rules=yes|gap=2em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
 
 
===Usage of "small" parameter===
; Example showing how setting "small" parameter to "yes" produces smaller font size
<pre>
{{Div col|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
</pre>
; produces:
{{Div col|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
 
===Usage of "content" parameter===
; Example showing how to provide "content" parameter without using {{tlx|Div col end}}
<pre>
{{Div col|colwidth=10em|content=
* a
* b
* c
* d
* e
* f
* g
* h
}}
</pre>
; produces:
{{Div col|colwidth=10em|content=
* a
* b
* c
* d
* e
* f
* g
* h
}}
 
===Usage with multiple named parameters===
When parameters are named in the template, they can be used in any order.
'''Example: '''
<pre>
{{Div col|colwidth=10em|rules=yes|gap=2em|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
</pre>
or
<pre>
{{Div col|rules=yes|gap=2em|small=yes|colwidth=10em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
</pre>
; produces:
{{Div col|colwidth=10em|rules=yes|gap=2em|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
and exactly the same result below
{{Div col|rules=yes|gap=2em|small=yes|colwidth=10em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
 
 
; Example with column width of 20em
<pre>
{{div col|colwidth=20em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
</pre>
; produces:
{{Div col|colwidth=20em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
 
; Example with column width of 30em
<pre>
{{div col|colwidth=30em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
</pre>
; produces:
{{Div col|colwidth=30em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
 
; Example of how this template behaves if no [[•|bullets]] (generated by asterisk mark) are used. 
<pre>
{{div col|colwidth=10em}}
a
b
c
d
e
f
g
h
{{div col end}}
</pre>
; produces:
{{Div col|colwidth=10em}}
a
b
c
d
e
f
g
h
{{Div col end}}
 
==Deprecated usage==
 
===Usage without parameters===
''Usage of fixed column counts is deprecated, therefore this example should no longer be used as well. For a fixed number of columns, use a template from the [[#See also|See also]] section below.''
<s>Example with no parameters produces two columns as the default is two columns.</s>
<s><nowiki>{{Div col}}</nowiki></s>
<s><nowiki>* a</nowiki></s>
<s><nowiki>* b</nowiki></s>
<s><nowiki>* c</nowiki></s>
<s><nowiki>* d</nowiki></s>
<s><nowiki>* e</nowiki></s>
<s><nowiki>* f</nowiki></s>
<s><nowiki>* g</nowiki></s>
<s><nowiki>* h</nowiki></s>
<s><nowiki>{{Div col end}}</nowiki></s>
; <s>produces:</s>
{{Div col}}
* <s>a</s>
* <s>b</s>
* <s>c</s>
* <s>d</s>
* <s>e</s>
* <s>f</s>
* <s>g</s>
* <s>h</s>
{{Div col end}}
 
===Usage of parameters without naming the parameters===
''Usage of fixed column counts is deprecated, therefore this example should no longer be used as well. For a fixed number of columns, use a template from the [[#See also|See also]] section below.''
When parameters are not named, the template considers the first unnamed parameter to be "cols" and the second unnamed parameter to be "colwidth". Any additional unnamed parameters (e.g. third, fourth, fifth, etc. unnamed parameter) will be ignored by the template and will show an error message when previewing the page.     
;Example with usage of (deprecated) unnamed parameters
Note the empty column for the "number of columns" between "Div col" and "10em".
<pre>
{{div col||10em|rules=yes|gap=2em|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
</pre>
; produces
{{div col||10em|rules=yes|gap=2em|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
 
===Usage of "cols" parameter===
Important: Use of now-[[Deprecation|deprecated]] "cols" parameter (equivalent to the first unnamed parameter) is discouraged, leave it blank and instead use the "colwidth" parameter. For a fixed number of columns, use a template from the [[#See also|See also]] section below.
{{cot|deprecated example|bg=lightgray}}
; Example with 3 columns
<pre>
{{Div col|3}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
</pre>
; produces:
{{Div col|3}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
 
; Example with 4 columns
<pre>
{{Div col|4}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
</pre>
; produces:
{{Div col|4}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
{{cob}}
 
==Tracking categories==
*{{clc|Pages using div col with deprecated parameters}} (for use of {{para|cols}} and unnamed parameters)
*{{clc|Pages using div col with unknown parameters}} (for erroneous use of parameter names not documented here)
 
==TemplateData==
{{TemplateDataHeader}}
{{#switch: {{BASEPAGENAME}}
|Div col=<templatedata>
{
"description": "Breaks a list into columns. It automatically breaks each column to an equal space, so you do not manually have to find the half way point on two columns. The list is provided by |content= or closed with {{div col end}}.",
"params": {
"cols": {
"label": "cols",
"description": "Specifies the number of columns.",
"type": "number",
"default": "2",
"aliases": [
"1"
],
"required": false,
"deprecated": "Use colwidth parameter instead, so that the layout resizes according to the screen"
},
"colwidth": {
"label": "Column width",
"description": "Specifies the width of columns, and determines dynamically the number of columns based on screen width; more columns will be shown on wider displays. This overrides the 'cols' setting.",
"type": "string",
"aliases": [
"2"
],
"required": false,
"example": "30em",
"suggested": true
},
"rules": {
"label": "Rules",
"description": "Produces vertical rules between the columns if set to yes.",
"type": "string",
"required": false,
"example": "'yes' or '1px dashed blue'"
},
"gap": {
"label": "Gap size",
"description": "Specifies the space between the content of adjacent columns.",
"type": "string",
"required": false,
"example": "2em"
},
"style": {
"label": "CSS style",
"description": "Specifies any custom styling.",
"type": "string",
"required": false
},
"content": {
"label": "Content",
"description": "Specifies the content to divide into columns",
"type": "string",
"required": false
},
"small": {
"label": "Small font",
"description": "Use a smaller font size (90%)",
"example": "yes",
"type": "boolean",
"default": "no"
}
}
}
</templatedata>
|Div col end=<templatedata>
{
    "description": "Ends a multi-column list started by {{div col}}. It takes no parameters.",
    "params": {
    }
}
</templatedata>
}}
 
==Redirects==
{{#ifeq:{{ROOTPAGENAME}}|Div col|
* {{Tlx|Div col start}}
* {{Tlx|Div col begin}}
* {{Tlx|Colbegin}}  (but '''not''' {{Tlx|Col begin}})
* {{Tlx|Cols}}
}}
{{#ifeq:{{ROOTPAGENAME}}|Div col end|
*{{Tlx|Col div end}}
*{{Tlx|Colend}} (but '''not''' {{Tlx|Col end}})
*{{Tlx|Div end}}
*{{Tlx|Divcol-end}}
*{{Tlx|Divcolend}}
*{{Tlx|Divend}}
*{{Tlx|End div col}}
*{{Tlx|EndDivCol}}
}}
 
==See also==
{{Column-generating template families}}
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox |
| <!-- CATEGORIES BELOW THIS LINE, PLEASE: -->
[[Category:Multi-column templates]]
 
<!--?:-->{{#switch:{{PAGENAME}} |Div col= |Div col end=}}
[[es:Plantilla:Div col]]
}}</includeonly>

Latest revision as of 00:08, 3 February 2024

{{#invoke:Check for unknown parameters|check|unknown=Template:Main other|preview=Page using Template:Div col with unknown parameter "_VALUE_"; use colwidth= to specify column size |ignoreblank=y | colwidth | content | gap | rules| style }}

  1. Template:Tl forces the auto-generated Table of Contents for an article to appear in a table that is floated to the right side of the page, in order to improve article layout.

Usage

Insert {{Div col}} at the point in the article where you want the top of the Table of Contents box to appear. This should usually be after the text of the lead section, and just before the first section heading, in accordance with Wikipedia:Lead section#Elements of the lead. Use with Template:Tl or Template:Tl to prevent collision with text; use the clear parameter (see below) to prevent collision with images.

Parameters (optional)

clear
Sets the CSS clear property, which forces this float underneath the side specified with this attribute. So, clear=right (which is the default) will place the element after all the right floating elements before it. Options are left, right, both, or none.
width
Set the CSS width.
limit
Limits the depth of subheadings shown. For instance using limit=4 will hide the fourth level and deeper subheadings in the hierarchy. And limit=2 will hide all subheadings leaving only the main headings. This is implemented as a CSS class in the MediaWiki:Common.css.
  • Avoid placing the TOC in a visually poor location. Crossing a section division is probably a poor idea.
  • If the TOC is floated left of a bulleted list, the bullets will be hidden.

Cautions

Do not use this template to just force word wrap around the TOC, as this is inappropriate method of achieving this. Instead add a CSS class to your current skin's .css file, which will apply site wide. Go to Special:Mypage/skin.css, which redirects to your current skin's CSS file.

Do not place this template so that the TOC aligns with a large image or infobox; this breaks the layout on narrow screens (even users with screens as wide as 1024px wide can have problems). Also, a TOC that crosses a section division is probably a poor idea, if that can be avoided.

Unless the section in which the Template:Tl is placed is long enough, the result may well be undesirable.

It should only be used in cases where the TOC gets in the way of other content or is detrimental to the layout of the page; it should not simply be used for aesthetics since it tampers with the standard appearance of articles. See Help:Section#Floating the TOC for further guidelines.

See also



ar:قالب:فهرس يمين ro:Format:Cuprins dreapta ur:سانچہ:دائیں فہرست