Template talk:Decade years navbox
Template:Decade years navbox has been protected indefinitely because it is a highly-used or visible template. Use {{Edit request}} on this page to request an edit. |
Red links
[edit]--anro (talk) 01:56, 31 January 2012 (UTC)
Maximum of four flagicons?
[edit]Howdy. I'm trying to add historical flagicons for various years into the header but seem to be limited to four flagicon images tops before the template stops working. Is there any way to add more than four images to the header? See here and here for an example of this in action. – Illegitimate Barrister (talk) 05:24, 30 November 2017 (UTC)
Year max
[edit]It would be nice if there was a way to set a max parameter for the years. For example, Category:Abdullah_of_Saudi_Arabia_in_2014. He died in 2015 so we don't need links for 2016 onwards. // sikander { talk } 02:26, 6 January 2019 (UTC)
- Hold on, I suppose displayredlinks takes care of that. // sikander { talk } 02:27, 6 January 2019 (UTC)
Excess space around year in cat link?
[edit]I'm trying to get {{Photographer by year}} working with category links in the forms of both "Year <foo>" or "Foo (Year)". Depending on whether the subcat param "in Paris" is given, this will give either
or
But what I'm actually getting is:
As is not unusual with wikicode, |cat_prefix=
|cat_suffix=
are always embedding an unwanted space in there, even when the brackets should be tight around the year.
Is there a work-around for this? Should I fix it in {{Decade years navbox}}, or is that already proven that it will break too much existing work?
{{Decade years navbox | header = [[:Category:Photographs by Willem van de Poll|Photographs by Willem van de Poll]] | decade = 195 | cat_prefix = | cat_suffix =photographs by Willem van de Poll }} {{Decade years navbox | header = [[:Category:Photographs by Willem van de Poll|Photographs by Willem van de Poll in Paris]] | decade = 195 | cat_prefix =Photographs by Willem van de Poll in Paris ( | cat_suffix =) }}
Thanks Andy Dingley (talk) 11:36, 28 February 2019 (UTC)
- Looks like the simplest, and most backwards-compatible way is to introduce a new parameter of
|padding=
, which will default to a single space. In the case above, it can be set explicitly to null '' instead. Andy Dingley (talk) 12:33, 28 February 2019 (UTC)- @Andy Dingley I'm having the same problem... This was never fixed, right? Darwin Ahoy! 23:27, 4 February 2024 (UTC)
- Fixed in 2019 [1], or at least the work-around above was implemented. So {{Photographer by year}} works fine since. Andy Dingley (talk) 23:59, 4 February 2024 (UTC)
- @Andy Dingley I'm having the same problem... This was never fixed, right? Darwin Ahoy! 23:27, 4 February 2024 (UTC)
displayredlinks=maybe
[edit]Hello, I am doing lots of clean up in images by dates categories. And I wanted to have a feature that didn't exist, so I've put that in. Now you can do |displayredlinks=maybe
to show red links in case if there are pages in those categories. The code looks larger than needs to be, that is because I wanted to make sure that {{PAGESINCATEGORY}} is only called if the link is actually red. ℺ Gone Postal (〠 ✉ • ✍ ⏿) 16:01, 28 January 2020 (UTC)
New version displaying range by minyear and maxyear
[edit]{{Edit request}} Since the possibility to limit years to display is needed, I have attempted to create a version that allows this. Because of the protection on the template, I've had to add it as a subpage on {{Decade years navbox/minmax}}.
By setting displayredlinks=minmax
(which is set to default in my test), the year range can be limited by setting minyear
(default 0) and maxyear
(default 9999). It is entirely based on simple calculations, so I hope that it will not be slow, but I don't know how that is measured.
I have tested it on some pages (but only in preview, so no pages link to it yet), and it seems to work fine. Could somebody else check how it works? And obviously somebody with sufficient rights add it to the main template if it is good enough.
BTW, I see that the <noinclude>202</noinclude>
code that is used to display correctly on the Template page appears 124 times, and if my code with 46 of them is added, it will be a total of 170 times! Perhaps it would be better to use "includeonly" and instead transclude the template on itself to only set this value one single time? Is there any good reason why this hasn't been done? It would make the code quite more readable, and we would even save som Bytes. Or, as far as I understand, the Template page only show the default value of displayredlinks, so only 22 of them will ever be displayed at all. Bergenga (talk) 21:00, 29 June 2022 (UTC)
- A week has passed and nothing happened, except that I ran out of patience and have started to implement it on templates with linking to my temporary subpage solution. Could an administrator or template editor please insert the code into the main template? It shouldn't by any means break any of the existing functionality, only add new via a new setting of displayredlinks. It is from line 8 and including line 45 in my code that should be copied, and pasted before line 46 (or 108) in the main template code. I'll happily redirect my implementations (42 so far) to the main template when it is done.
- I don't have any exact measurement, but after using it for a while, I can't really tell the difference in loading time between
displayredlinks=minmax
anddisplayredlinks=yes
(default). Butdisplayredlinks=no
feels quite slow in comparison, and I haven't even considered tryingdisplayredlinks=maybe
. There is one major bug with my code, and that is if you set minyear or maxyear, but leave it empty, it creates a dozen rather nasty messages with "Expression error: Missing operand for >=.". It will also behave similarly if they are set to something that is not a number. Unfortunately, I don't know the syntax here well enough to know how to fix that, so for now we can only hope that people will not do it that way. As these errors are only created by wrong usage, I don't see it as critical. Bergenga (talk) 07:47, 7 July 2022 (UTC)- Done Bergenga just noticed your request. If you are still around, can you add documentation to Template:Decade years navbox/doc? --Jarekt (talk) 02:45, 4 July 2024 (UTC)
- Thanks! :) Yes, I am still around, but real life has been getting in the way of me doing much here lately, and it is not likely to change radically in the very near future, so the only thing I can promise is that I'll make sure to update the doc some time during the autumn. At best I'll be able to do it in a couple of weeks.
- I have now made the /minmax subpage a redirect to the main template, so all usage is directed that way. If somebody wants to run a bot job on skipping the redirect, you are welcome, but it is not worth prioritizing in any way. Bergenga (talk) 20:30, 27 July 2024 (UTC)
- Finally got an idea for how to do the description and got around to do it. English is not my native language, and I'm not a very pedagogical person, so I'm definitely open for somebody else doing improvements to it. Bergenga (talk) 18:53, 7 August 2024 (UTC)
- Done Bergenga just noticed your request. If you are still around, can you add documentation to Template:Decade years navbox/doc? --Jarekt (talk) 02:45, 4 July 2024 (UTC)
Link to header
[edit]{{Editprotect}} if [[:cat:header]] exists, then it should be a link. this makes it easy to one click go back to the topic cat.
change line 5 to
| <dt>{{#ifexist:Category:{{{header|}}}|[[:Category:{{{header|}}}|{{{header|}}}]]|{{{header|<noinclude>Header</noinclude>}}}}} </dt> RZuo (talk) 15:10, 5 May 2023 (UTC)
- @RZuo: Sounds fine to me. I noticed while looking through Special:WhatLinksHere/Template:Decade years navbox that a lot of more specific templates already seem to do this, such as {{Birthcat}}, {{Deathcat}}, {{BooksYear}}, but also some individual categories like Category:2006 Australian Open. I assume those cases can then be simplified? --Lucas Werkmeister (talk) 15:46, 25 June 2023 (UTC)
- yes, they need to be modified after this proposal is adopted. RZuo (talk) 16:21, 25 June 2023 (UTC)
- Done @RZuo: --Jarekt (talk) 01:56, 4 July 2024 (UTC)
- thx a lot. i edited a few templates accordingly. RZuo (talk) 09:16, 5 July 2024 (UTC)
- Done @RZuo: --Jarekt (talk) 01:56, 4 July 2024 (UTC)
- yes, they need to be modified after this proposal is adopted. RZuo (talk) 16:21, 25 June 2023 (UTC)
- @Reinhard Müller: I think due to this edit the mechanism in {{Editprotect}} that adds default comments to the edits picked your name for this edit instead of User:RZuo. Sorry about confusion. --Jarekt (talk) 02:02, 4 July 2024 (UTC)
- @Jarekt: No problem, thanks for letting me know. --Reinhard Müller (talk) 06:28, 4 July 2024 (UTC)
- This breaks {{Person in year}} where we create two links to two different categories and the complete header is the name of the second category. For example: [[:Category:Julie Andrews|Julie Andrews]] [[:Category:Julie Andrews by year|by year]] which creates Julie Andrews by year. But with your change the header disappears completely. XxakixX (talk) 11:10, 5 July 2024 (UTC)
- i dont know why that happens. maybe it has to do with the complicated design of that template that results in a big bloc of code that maybe fails.
- because the new code is simple, given a "header", if cat:header exists then it will be displayed, otherwise it will just show whatever the "header" is, which means, for that template, it should continue to show Julie Andrews by year.
- take a look at these codes https://commons.wikimedia.org/w/index.php?title=Commons:Sandbox&oldid=892591063 . you see, the code itself isolated will display the links properly, but as part of the template it will not. RZuo (talk) 13:26, 5 July 2024 (UTC)
@Jarekt: since your edits three days ago, I can not see header in many templates any more. --Orijentolog (talk) 06:23, 7 July 2024 (UTC)
- @Orijentolog please point to which templates are affected. RZuo (talk) 10:57, 7 July 2024 (UTC)
- Template:US cities by year is affected. Eco84 (talk) 14:07, 7 July 2024 (UTC)
- @RZuo: templates like Template:US cities by year that have a lot of wikicode in the header, are not fixable with our new change without rewrite or each individual template. I had issues in the past that #ifexist function had unpredictable behavior when input is anything other than a simple string. I think we should revert and maybe implement new parameter "autoheader" (or something) that when present would take precedent and do what the current code does. Or just go back to the original. --Jarekt (talk) 15:11, 7 July 2024 (UTC)
- yes. i have no problem with reverting to the original (no auto link) header design. RZuo (talk) 16:43, 7 July 2024 (UTC)
- after checking Template:US cities by year...
- i always feel that commons should have a one for all template, at least for categories of the same kind.
- like all "location x month" cats should get 1 single template, instead of each country/province/state getting its own...
- Template:Category description/Year by city could be something neater for usa and any other country's cities. RZuo (talk) 16:48, 7 July 2024 (UTC)
- one common problem with these failing templates is that they all like to have a small picture in the "header".
- so a solution to simplify that is to add an "icon" parameter. afaiu, this template is just a table, right? i will look into this shortly. RZuo (talk) 20:32, 7 July 2024 (UTC)
- @RZuo: templates like Template:US cities by year that have a lot of wikicode in the header, are not fixable with our new change without rewrite or each individual template. I had issues in the past that #ifexist function had unpredictable behavior when input is anything other than a simple string. I think we should revert and maybe implement new parameter "autoheader" (or something) that when present would take precedent and do what the current code does. Or just go back to the original. --Jarekt (talk) 15:11, 7 July 2024 (UTC)
- @RZuo: templates like {{Jameh Mosque of Yazd-year}} and virtually everything in Category navigational templates for architecture in Iran. What should be manually changed to fix it? --Orijentolog (talk) 18:15, 7 July 2024 (UTC)
- Template:US cities by year is affected. Eco84 (talk) 14:07, 7 July 2024 (UTC)
- i think the "str <= len" template used is the problem, so any header > 40 chars is hidden by design.
- why the filter? RZuo (talk) 21:54, 7 July 2024 (UTC)
- @Jarekt or do you mean, for long "header" values, you want to skip the ifexist hack right? then you need to add the outcome for when str len > 40!
- </dt>
- }}}}<!-
- should become
- </dt>
- |{{{header}}}
- }}}}<!- RZuo (talk) 21:59, 7 July 2024 (UTC)
- @RZuo Good catch, that was an issue. Hopefully it is fixed now. The filter was attempting to recognize cases where there is a bunch of complicated wikicode in the header and just return the original. Chances are that header longer than 40 characters is not a name of a category. --Jarekt (talk) 22:21, 7 July 2024 (UTC)
- @Jarekt i think you fixed it the wrong way? the new |{{{header}}} should be inside str <= len
- so it should be
- |{{{header}}} }} }} RZuo (talk) 23:28, 7 July 2024 (UTC)
- I sure did. Should be OK now. --Jarekt (talk) 00:22, 8 July 2024 (UTC)
- @Jarekt just one more thing.
- take a look at Category:Julie Andrews in 2019 for example.
- some space or punctuation is needed between the header and the links.
- https://commons.wikimedia.org/w/index.php?title=Template:Decade_years_navbox&diff=894239208&oldid=574441403
- you deleted   and  . RZuo (talk) 08:47, 8 July 2024 (UTC)
- RZuo, I also had some issues with html tags. Hopefully it is OK now. --Jarekt (talk) 12:38, 8 July 2024 (UTC)
- @RZuo Good catch, that was an issue. Hopefully it is fixed now. The filter was attempting to recognize cases where there is a bunch of complicated wikicode in the header and just return the original. Chances are that header longer than 40 characters is not a name of a category. --Jarekt (talk) 22:21, 7 July 2024 (UTC)
- @XxakixX @Orijentolog @Eco84 please check if there's still any problem. RZuo (talk) 08:38, 8 July 2024 (UTC)
- Looks good now, thank you. XxakixX (talk) 13:35, 8 July 2024 (UTC)
- Yeah, now it's fine. --Orijentolog (talk) 16:31, 8 July 2024 (UTC)
- Everything looks good now. Eco84 (talk) 21:05, 8 July 2024 (UTC)
Alternative approach
[edit]I would like to point everybody interested to this discussion about a new approach for these navigation boxes. -- Reinhard Müller (talk) 09:58, 16 March 2024 (UTC)
New left and right arrows will be smarter
[edit]The left and right arrows in the box will be smarter. See for examples Category:Buildings in Scotland photographed in 2020 and Category:2015 in tram transport in Kumamoto. These arrows can reach the nearest year in the previous/following decade, if any such category exists. Before this revision, it can only reach the last/first year of the previous/following decade, which often make users difficult to browse the neighboring decade. Note that these smart arrows work only if the value of the parameter |displayredlinks=
is either yes
or no
or blank. --トトト (talk) 01:03, 15 September 2024 (UTC)