Template talk:Decade years navbox

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Red links[edit]

English: someone - its too complicate for me - schould review this template that all years appear as "ifexist" to avoid red links
Deutsch: jemand sollte hier mal drübergehen, damit die "roten links" nicht mehr angezeigt werden
Français : q.un pourrait revoir ce template a anuller les links rouges

--anro (talk) 01:56, 31 January 2012 (UTC)[reply]

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)[reply]

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)[reply]

Hold on, I suppose displayredlinks takes care of that. // sikander { talk } 02:27, 6 January 2019 (UTC)[reply]

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

Category:1950 photographs by Willem van de Poll

or

Category:Photographs by Willem van de Poll in Paris (1950)

But what I'm actually getting is:

Category:Photographs by Willem van de Poll in Paris ( 1950 )

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 =)
}}
Photographs by Willem van de Poll
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
Photographs by Willem van de Poll in Paris
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959

Thanks Andy Dingley (talk) 11:36, 28 February 2019 (UTC)[reply]

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)[reply]
@Andy Dingley I'm having the same problem... This was never fixed, right? Darwin Ahoy! 23:27, 4 February 2024 (UTC)[reply]
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)[reply]

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)[reply]

New version displaying range by minyear and maxyear[edit]

It is requested that an edit or modification be made to this protected page.
Administrators/template editors: Please apply <nowiki> or {{Tl}} to the tag after the request is fulfilled.

Reinhard Müller

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)[reply]

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 and displayredlinks=yes (default). But displayredlinks=no feels quite slow in comparison, and I haven't even considered trying displayredlinks=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)[reply]

Link to header[edit]

It is requested that an edit or modification be made to this protected page.
Administrators/template editors: Please apply <nowiki> or {{Tl}} to the tag after the request is fulfilled.

Reinhard Müller

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)[reply]

@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)[reply]
yes, they need to be modified after this proposal is adopted. RZuo (talk) 16:21, 25 June 2023 (UTC)[reply]

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)[reply]