Template talk:Div col
![]() | Template:Div col is permanently protected from editing because it is a heavily used or highly visible template. Substantial changes should first be proposed and discussed here on this page. If the proposal is uncontroversial or has been discussed and is supported by consensus, editors may use {{edit template-protected}} to notify an administrator or template editor to make the requested edit. Usually, any contributor may edit the template's documentation to add usage notes or categories.
Any contributor may edit the template's sandbox. Functionality of the template can be checked using test cases. |
This is the talk page for discussing improvements to the Div col template. |
|
Archives: 1Auto-archiving period: 3 months ![]() |
Orphaned caption problem
[edit]There's a problem when {Div col} contains a [File:...] item providing a caption (as is usual) that I noticed in this article version (since worked around). At certain window sizes (in Chrome at least) the caption gets separated from the image itself. In the two-column version of that page (using "|right" placement), the caption can be widely separated from the image by intervening text flowing to the left of the caption and the right of the image. There are workarounds, but an editor has to know that the problem could occur even if their window width doesn't happen to show any problem. So, it seems like at a minimum the documentation for this template should call out the problem and potential solutions, or, better, the software should automatically avoid this problem with the [File:...] mechanism, either inside that mechanism or in this template mechanism. - R. S. Shaw (talk) 21:45, 17 June 2024 (UTC)
- I am able to reproduce this display problem in Brave for Mac (Vector 2022, desktop view). This bug was reported in 2018 as T193163, and it appears to be a bug in Chromium. I have added a note to the documentation. – Jonesey95 (talk) 22:15, 17 June 2024 (UTC)
Should take "width" and not just "colwidth"
[edit]![]() | This edit request has been answered. Set the |answered= parameter to no to reactivate your request. |
<includeonly><templatestyles src="Div col/styles.css"/><!--
--><div class="div-col {{#ifeq:{{{small|}}}|yes|div-col-small}} {{#ifeq:{{{rules|}}}|yes|div-col-rules}} {{{class|}}}" <!--
-->{{#if:{{{colwidth|{{{width|}}}}}}{{{gap|}}}{{{style|}}}|<!--
-->style="{{#if:{{{colwidth|{{{width|}}}}}}|column-width: {{{colwidth|{{{width}}}}}};}}{{#if:{{{gap|}}}|column-gap: {{{gap}}};}}{{#if:{{{style|}}}|{{{style}}}}}"<!--
-->}}><!--
-->{{#if:{{{content|}}}|{{{content}}}</div>}}<!-- Inventory how many pages use small=yes
-->{{#ifeq:{{{small|}}}|yes|[[Category:Pages using div col with small parameter]]}}<!--
--></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 | class | colwidth | content | gap | rules | small | style }}<noinclude>
{{Documentation}}
</noinclude>
See what I did? There's a {{{width|}}}
in this version so that it can work with that param or "colwidth". This shouldn't break anything, but seeing as this is on 400,000 pages I want to run this by someone else for a sanity check first. Is this going to bust anything? jp×g🗯️ 21:02, 7 July 2024 (UTC)
- I think you also need to add width as an option for the "Check for unknown parameters" part as well. -- WOSlinker (talk) 21:36, 7 July 2024 (UTC)
- With any widely used template it is usually wise to put new code into the /sandbox version of the template and then create a few test cases on the /testcases page to show that it works without breaking anything. Something as simple as a missing or extra pipe character is easy to put into suggested code, but it will turn up problems on a well constructed testcases page. – Jonesey95 (talk) 00:48, 8 July 2024 (UTC)
- Well, the change is trivial, so I guess you're asking if you have consensus for it...? I'm not in favor of adding aliases for parameters in templates already widely used as this parameter is. Izno (talk) 11:09, 12 July 2024 (UTC)
- And actually, a better reason not to use that name is that one might want in some future to make the container have a smaller width rather than set the column width, the name for which would probably best be width. Colwidth alone seems fine. Izno (talk) 11:11, 12 July 2024 (UTC)
Not done for now: please establish a consensus for this alteration before using the
{{Edit template-protected}}
template. I agree with Izno that|width=
could be confusing and might be useful later for an overall width of the column set. Generally we try to reduce the number of aliases for parameters, not increase them. – Jonesey95 (talk) 14:34, 12 July 2024 (UTC)
Dynamic column width instead of fixed width
[edit]Is it possible for the column width to be specified as a percentage of the available table or page width? For example, {{Graphic novel list}} renders whitespace in |ChapterListCol2=
if it doesn't span the same number of rows as |ChapterListCol1=
; see List of Monogatari novels for several examples of this whitespace. I have previewed listing the chapters using |colwidth=50%
and |colwidth=40%
, but it rendered the columns at 30em. — Jkudlick ⚓ (talk) 01:45, 21 August 2024 (UTC)
- Percentage is not an absolute or relative length unit. Try
|colwidth=40vw
or a similar number between 10 and 50. That says "columns should be 40% of their container's width". Test it by making your window wider and less wide. It works on the template's testcases page. – Jonesey95 (talk) 04:17, 21 August 2024 (UTC)- Thank you. Perhaps the variable width should be added to the documentation? — Jkudlick ⚓ (talk) 19:48, 23 August 2024 (UTC)
- Seconded. —DocWatson42 (talk) 04:36, 25 November 2024 (UTC)
- You don't have to second anything. See Template:Div col#Examples. – Jonesey95 (talk) 04:57, 25 November 2024 (UTC)
- Oh, well. There had been no reply, so I assumed that it had not been done. —DocWatson42 (talk) 05:03, 25 November 2024 (UTC)
- You don't have to second anything. See Template:Div col#Examples. – Jonesey95 (talk) 04:57, 25 November 2024 (UTC)
- Seconded. —DocWatson42 (talk) 04:36, 25 November 2024 (UTC)
- Thank you. Perhaps the variable width should be added to the documentation? — Jkudlick ⚓ (talk) 19:48, 23 August 2024 (UTC)
- This sounds like an attempt to circumvent the cunsensus arrived at on this talk page to remove the
|cols=
parameter, which was actioned more than six years ago. See Template talk:Div col/Archive 1#1= and 2= and cols= no longer supported. --Redrose64 🌹 (talk) 19:00, 25 November 2024 (UTC)- The reason that was removed was because the implementations of columns was not particularly good at the time. I've been considering a discussion to reintroduce some sort of
|max-columns=
parameter, which would use the already-existing|colwidth=
(or default) and then set the column count on top of that. When both width and count are provided, CSS columns treat the column count as a maximum rather than a required number of columns. The primary issue with columns before was that they were being set without the column width, which treated them as the required count, which is the general problem child especially on low resolutions. Izno (talk) 03:12, 22 May 2025 (UTC)
- The reason that was removed was because the implementations of columns was not particularly good at the time. I've been considering a discussion to reintroduce some sort of
Template-protected edit request on 19 September 2024
[edit]![]() | This edit request has been answered. Set the |answered= parameter to no to reactivate your request. |
Please inclde these names under Notable teachers
- Graham Hair, composition
- Bozidar Kos, composition
- Trevor Pearce, composition
- Greg Schiemer, composition and electronic music
- Michael Smetanin, composition
- Richard Vella, composition
- Martin Wesley-Smith, composition and electronic music
- Gillian Whitehead, composition Greg Schiemer (talk) 12:41, 19 September 2024 (UTC)
Not done: this is the talk page for discussing improvements to the template
{{Div col}}
. Please make your request at the talk page for the article concerned. Sohom (talk) 13:08, 19 September 2024 (UTC)
Horizontal sorting
[edit]Is it possible to get sorting of a list like so:
- Consul
- Praetor
- Aedile
- Quaestor
Instead to present as
Consul Praetor Aedile Quaestor
Ifly6 (talk) 01:00, 18 February 2025 (UTC)
- Are you talking about sorting or transposition? Because that sort of looks like the latter, although maybe it is just an artefact of being a 2 x 2 example. Another before & after example might help, this time with a 4-row, 3-column table. Mathglot (talk) 08:58, 18 February 2025 (UTC)
(outdent) I suppose then, with 12 items:
1 2 3 4 5 6 7 8 9 10 11 12
Using {{div col}} right now it would display as
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
Ifly6 (talk) 14:22, 18 February 2025 (UTC)
- {{grid list}} would do what you want, as would setting each list item to display: inline-block as with Module:List. It cannot be done with div col. Izno (talk) 03:09, 22 May 2025 (UTC)
- Ifly6, perhaps Izno already solved it for you but I still do not understand your question and do not see the sorting involved in your previous attempt. Do you still need this? If so, please specify both an input, as well as your sorted output, otherwise I do not see how to respond. Do you want to take the digits 1 to 12 in an already sorted input file, and display them as a 4 x 3 column table? Is that the question? Do you want to take unsorted input (example, please!) and sort it, displaying the results in columns? Mathglot (talk) 03:29, 22 May 2025 (UTC)
- I'm not sure how I would make it much simpler. The actual problem I want to solve is here: Template:Politics of the Roman Republic. There is a two-column {{div col}} right now, but the list of links under Magistrates is wrongly ordered in the way I described above.
- It doesn't seem that {{grid list}} solves the issue. I can't get the columns to be small enough to fit within the side bar. Ifly6 (talk) 03:47, 22 May 2025 (UTC)
- Grid list does solve the issue of getting things in the order you want in the number of columns you want, it just doesn't actually line things up in a grid, because it's actually a flex list and not a grid list. Sigh @ whoever named it that. It only has about 60 uses so renaming it wouldn't cause too much grief but then I'd have to do work implementing a grid. :') Izno (talk) 04:50, 22 May 2025 (UTC)
- Ok, I've added an example on the template of interest with {{flex list}} as well as a new parameter to support this kind of case. Izno (talk) 05:14, 22 May 2025 (UTC)
- For some reason it seems to display just like a horizontal list with no bullets between?
- I think I'd still want the columns for spacing. Ifly6 (talk) 16:45, 22 May 2025 (UTC)
- The "10em" is not a thing. But yeah, I see what you mean. I was afraid that would be an issue. What you indeed want is some sort of actual {{grid list}}. I'm not sure how that should be supported ultimately as supporting smaller resolutions would need to be thought about, but it's probably not difficult on the face of it and just needs someone to do it. Izno (talk) 19:37, 22 May 2025 (UTC)
- Ok, I've hacked together a really basic {{grid list}} as a proof of concept. I'm not sure what I want to name it, but it does what it says on the tin. Only supports two columns, and the columns parameter is soft required, yadda yadda. Izno (talk) 19:56, 22 May 2025 (UTC)
- And now documentation. Izno (talk) 20:05, 22 May 2025 (UTC)
- That's fantastic. Is it stable (enough) to use in a sidebar? Thanks! Ifly6 (talk) 20:48, 22 May 2025 (UTC)
- There's nothing particularly unstable about it if you understand CSS grid. I just don't know if the template is worth it, rather than perhaps a solution specific to that sidebar with its own TemplateStyles. I'm inclined to keep the template because I suspect not all uses of {{aligned table}} are accessibility kosher, but then it might turn out this template isn't used anywhere besides your template after all. (And I don't know/want there to be big extensions on the thing necessarily........) But sure, go for it. Izno (talk) 21:28, 22 May 2025 (UTC)
- That's fantastic. Is it stable (enough) to use in a sidebar? Thanks! Ifly6 (talk) 20:48, 22 May 2025 (UTC)
- The "10em" is not a thing. But yeah, I see what you mean. I was afraid that would be an issue. What you indeed want is some sort of actual {{grid list}}. I'm not sure how that should be supported ultimately as supporting smaller resolutions would need to be thought about, but it's probably not difficult on the face of it and just needs someone to do it. Izno (talk) 19:37, 22 May 2025 (UTC)
- Ok, I've added an example on the template of interest with {{flex list}} as well as a new parameter to support this kind of case. Izno (talk) 05:14, 22 May 2025 (UTC)
- Grid list does solve the issue of getting things in the order you want in the number of columns you want, it just doesn't actually line things up in a grid, because it's actually a flex list and not a grid list. Sigh @ whoever named it that. It only has about 60 uses so renaming it wouldn't cause too much grief but then I'd have to do work implementing a grid. :') Izno (talk) 04:50, 22 May 2025 (UTC)
- Maybe this clarifies? I don't want anything resorted. I want it displayed in the sorted order just such that when displaying it iterates to the right instead of iterating down. Ifly6 (talk) 03:50, 22 May 2025 (UTC)
1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 |
- Do you know about creating tables at Wikipedia? They arrange things by default from left to right, up to the total number of columns you want. See Help:Table. If you are using the Visual Editor, it offers you some shortcuts to creating a table of a certain number of rows and columns, and then you just fill in the values in the cells. Would that solve your problem? In theory, Izno's grid solution is better, because tables are not supposed to be used just for layout, CSS should be. But the table approach might get you started, and then you can look into how to approach a grid starting from a table, which might be easier for you. Or, just jump straight to grid. Mathglot (talk) 09:18, 22 May 2025 (UTC)
- I tried putting a table in the sidebar but it didn't seem to render properly: it just shows a single
{
character. Ifly6 (talk) 16:42, 22 May 2025 (UTC) - This doesn't work because of the limitations of the | character having multiple meanings (in the context of a template, it looks like a template, not a table). There is at least 1 easy workaround for it({{Aligned table}}) and one harder (
{{!}}
) but you would indeed rely on using a table for presentation. Izno (talk) 19:37, 22 May 2025 (UTC)- (In some places, like {{History of Chad}}, {{aligned table}} is used more or less reasonably. I suspect in most others what is not had is a table and instead a presentational use of a table, as this case would be if such were used.) Izno (talk) 19:41, 22 May 2025 (UTC)
- @Ifly6: The main problem with the
|
character is that the template parser sees it as the start of a new parameter. For this reason, the{{!}}
magic word was created. There's a whole suite of templates, such as{{(!}}
(opening round bracket followed by exclamation point), that allow table markup to be passed as parameters. --Redrose64 🌹 (talk) 21:57, 22 May 2025 (UTC)
- I tried putting a table in the sidebar but it didn't seem to render properly: it just shows a single
- Do you know about creating tables at Wikipedia? They arrange things by default from left to right, up to the total number of columns you want. See Help:Table. If you are using the Visual Editor, it offers you some shortcuts to creating a table of a certain number of rows and columns, and then you just fill in the values in the cells. Would that solve your problem? In theory, Izno's grid solution is better, because tables are not supposed to be used just for layout, CSS should be. But the table approach might get you started, and then you can look into how to approach a grid starting from a table, which might be easier for you. Or, just jump straight to grid. Mathglot (talk) 09:18, 22 May 2025 (UTC)