Difference between revisions of "Template:Columns"
Jump to navigation
Jump to search
(This template should take one long list and display it as three, automatically balanced columns. It can tell if a list is too short (< 3) and not display an empty column.) |
m (typo'ed!) |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{#arraydefine:list|{{{1}}}|* | {{#arraydefine:list|{{{1}}}|* | ||
|sort=asc}}{{#arrayunique:list}}{{#arrayslice:notcol1|list|{{#expr: {{#arraysize:list}} / 3 | |sort={{{sort|asc}}}}}{{#arrayunique:list}}{{#arrayslice:notcol1|list|{{#expr: ceil({{#arraysize:list}} / 3)}}}}{{#arraydiff:col1|list|notcol1}}{{#arrayslice:col3|notcol1|{{#expr: {{#arraysize:notcol1}} / 2 round 0}}}}{{#arraydiff:col2|notcol1|col3}}{{#arrayslice:column2|list|{{#expr: {{#arraysize:list}} / 3 round 0}}}}{{#arrayslice:column3|column1|{{#expr: 2 * ({{#arraysize:list}} / 3) round 0}}}}{| {{{options|style="margin:0 auto;"}}} | ||
{| {{options|}} | |||
{{#ifeq: {{#arraysize:col1}} | 0 | | {{!}}style="vertical-align:top;"{{!}} | {{#ifeq: {{#arraysize:col1}} | 0 | | {{!}}style="vertical-align:top;"{{!}} | ||
<ul><li>{{#arrayprint:col1|</li><li>}}</li></ul>}} | <ul style="{{{liststyle}}}"><li>{{#arrayprint:col1|</li><li>}}</li></ul>}} | ||
{{#ifeq: {{#arraysize:col2}} | 0 | | {{!}}style="vertical-align:top;"{{!}} | {{#ifeq: {{#arraysize:col2}} | 0 | | {{!}}style="vertical-align:top;"{{!}} | ||
<ul><li>{{#arrayprint:col2|</li><li>}}</li></ul>}} | <ul style="{{{liststyle}}}"><li>{{#arrayprint:col2|</li><li>}}</li></ul>}} | ||
{{#ifeq: {{#arraysize:col3}} | 0 | | {{!}}style="vertical-align:top;"{{!}} | {{#ifeq: {{#arraysize:col3}} | 0 | | {{!}}style="vertical-align:top;"{{!}} | ||
<ul><li>{{#arrayprint:col3|</li><li>}}</li></ul>}} | <ul style="{{{liststyle}}}"><li>{{#arrayprint:col3|</li><li>}}</li></ul>}} | ||
|} | |} | ||
{{#arrayreset:}} | {{#arrayreset:}} |
Latest revision as of 17:16, 7 November 2014
|