Template talk:Archive list

ifexist limit
editprotected

This template generates 101 calls fo #ifexist. Per Village_pump_%28technical%29, the devs will be blocking all pages from making more than 100 calls to #ifexist for performance reasons, which would put all pages transcluding this immediately above the limit.

I would suggest restructuring this as 10 blocks based on 10 calls to #ifexist, rather than having an #ifexist call for each possible archive. Dragons flight 21:41, 1 December 2007 (UTC)


 * The template currently works the following way:
 * Link to archive 1.
 * Does archive 2 exist? If so, link to it. Otherwise, give up.
 * Does archive 3 exist? If so, link to it. Otherwise, give up.
 * Does archive 4 exist? If so, link to it. Otherwise, give up.
 * etc
 * This means that once the new algorithm for following #ifexist is used (where each branch is only followed when necessary), the pages transcluding this template should only make as many #ifexist calls as there are archive pages. In most cases, this number should be well below 101.
 * It would be possible to restructure the template to test if a block of pages exists, and narrow down from there until the exact number of archive pages is found. Depending on how it's implemented, this would generate approximately 8 #ifexist calls per page but it would be fairly complex to code and it would need to be tested in a sandbox before being put in the live version. Tra (Talk) 01:15, 2 December 2007 (UTC)
 * I've created a version at Template:Archive list/sandbox that should cut down on #ifexist calls once the new mechanism for parsing #if works (i.e. only look at the branches that need to be looked at, instead of all of them), but doesn't require this change to be made to the #ifexist mechanism. Tra (Talk) 21:55, 4 December 2007 (UTC)

I've updated Template:Archive list/sandbox with a version that doesn't use #ifexist at all. -- Fullstop (talk) 05:53, 8 January 2008 (UTC)
 * Disabled due to display:none issues. More info available here: HiddenStructure. Cheers. --MZMcBride (talk) 06:19, 8 January 2008 (UTC)

Links per line
Can the links per line be defined as I have done in the sandbox? Right now it is only #s that are multiples of 5, to keep the size down. MrKIA11 (talk) 17:06, 11 January 2008 (UTC)
 * I just want to point out the parameter name  isn't good, there's an HTML tag called nobr which does nowrap for text.   —Dispenser (talk) 19:17, 11 January 2008 (UTC)
 * I changed  to , but I think that even that is not the best name, I just can't think of anything short and sweet. Maybe   or  ? MrKIA11 (talk) 20:11, 11 January 2008 (UTC)
 * I'd like to see something a bit more flexible where I could specify a multiple to the line breaks to appear. —Dispenser (talk) 20:40, 11 January 2008 (UTC)
 * The sandbox version is based on another version that was rejected previously due to accessibility issues. Would it be possible to have the proposed method be based on the existing version at Template:Archive list? Tra (Talk) 20:51, 11 January 2008 (UTC)
 * I changed it to be based on the current version. I also changed it so it can take any multiple (up to 100 of course). As you can see though, it increases quite a bit in size. All of my changes I assume will work. I'm not very experienced with HTML, but from what I have read, what I did makes sense in my head. MrKIA11 (talk) 21:05, 11 January 2008 (UTC)
 * I've tested it a bit in a show-preview window and I think the main problem is that currently, there is by default a line break every 10 links and the line breaks can be disabled by setting . In the new version, the default is to have no line breaks unless otherwise specified. This may mess up existing uses of the template. Tra (Talk) 22:21, 11 January 2008 (UTC)
 * I'm not very sure about this stuff, but would putting at the beginning set the default for the   parameter to 10? MrKIA11 (talk) 22:30, 11 January 2008 (UTC)
 * Not done. There really isn't a compelling reason for #ifexist to not be used at the moment. rel2abs can cause serious issues when mixed with a CSS hack, as mentioned above. Also, nobr, while it is an HTML tag, is a perfectly fine parameter name, especially when it removes the presence of br tags. Unless there is a reason to update this template, it's my view that it should either be deprecated in favor of a bot doing the archive boxes or be left alone. --MZMcBride (talk) 22:55, 11 January 2008 (UTC)
 * I thought about using in place of just  but just having that on its own would cause the pages using nobr=yes to stop working, so extra code would be needed to handle the nobr=yes parameter. What I've done in the sandbox is to use the new code except for at the end of each group of 10 links, where it would check if links= has been specified, and if it hasn't been specified, it would insert a line break or comma depending on the presence of nobr=yes.
 * When testing this, the existing uses of archive list appear identical under the sandbox template (i.e. the template is fully backwards compatible), and when testing links=, this appears correctly too.
 * One other issue is that the size of the template is almost doubled. This means that under the old version, I could repeat the template 72 times on a page before it broke, but under the new version, the template can only be repeated 42 times. However, this testing was carried out by repeating links to an identical set of archives - in practical use, the template could only be used 5 times since it uses 100 #ifexist calls for each set of archive pages, and the limit is 500 #ifexist calls. Therefore, the increased size of the template should have negligible effect.
 * In response to MZMcBride, the css hack is no longer in use, and nobr is working correctly again. I think this change would be a good idea and should be implemented as it would allow greater flexibility in listing archives. Tra (Talk) 23:24, 11 January 2008 (UTC)
 * First of all, I think it would help if the admin actually read the code. The current template uses rel2abs and the sandbox version still uses #ifexist. The sandbox is the same as the current version, but with more options. Tra, when you say it can be used 5 times, do you mean on the same page? If so, why would it be on any given page more than once? Can the be placed again, so someone else can review it, or is that not allowed since it was already reviewed? MrKIA11 (talk) 23:42, 11 January 2008 (UTC)
 * Yes, that's 5 times per page, assuming that no other #ifexist calls are used on that page (or templates transcluded on to that page). If there are other #ifexist calls, the limit would come down. As an example of where it's used more than once, there's Village pump archive which links to the archives of each of the sub sections of the Village Pump. I'd rather not simply make the edit against the actions of another admin, so I'll contact MZMcBride to see what he thinks. Tra (Talk) 00:07, 12 January 2008 (UTC)

MrKIA11: I can say with certainty that this isn't the first template I've come across. : - ) Tra is free to implement this code, and you're free to re-activate the editprotected request, however, I will say that this template is border-line high use and its size will jump by about 10,000 bytes if it is updated. #ifexist is an incredibly helpful ParserFunction, though using it in this particular template probably isn't the best idea. As I said before, deprecating this template seems like a wiser choice to me, however, it's not my opinion that really matters here, and frankly, I don't really care about this template and its inner workings. Upon further review of the template, other than the increased size, it seems like perfectly fine code. It's a shame that #ifexist isn't more efficient, but eso es la vida. --MZMcBride (talk) 03:26, 12 January 2008 (UTC)
 * I was just commenting on the fact that you said There really isn't a compelling reason for #ifexist to not be used at the moment., even though it was in the sandbox code, and that you said rel2abs can cause serious issues when mixed with a CSS hack, even though it is in the current code. I agree that the size is a problem, which is why I originally suggested just having the  be a multiple of 5. This also makes me wonder why previous suggestions that make it smaller, such as the above section, were shot down. MrKIA11 (talk) 04:24, 12 January 2008 (UTC)
 * ✅ and added a note on the documentation about the performance impact.
 * With regard to the previous suggestions referred to, whilst making the template smaller is a good thing, if the changes requested introduce other problems then it is more likely they would be rejected because of that. Tra (Talk) 12:00, 12 January 2008 (UTC)
 * Thank you very much. MrKIA11 (talk) 13:46, 12 January 2008 (UTC)

editprotected I just noticed that every line was off by one number. I corrected the sandbox, could you please change the template. Thanks. MrKIA11 (talk) 14:23, 12 January 2008 (UTC)
 * ✅ Tra (Talk) 15:09, 12 January 2008 (UTC)

Parameter Usage
Could someone add:

to the end of the template, so that the parameter usage can be checked? MrKIA11 (talk) 18:29, 16 January 2008 (UTC)
 * ✅ Tra (Talk) 18:54, 16 January 2008 (UTC)
 * The new preprocessor changed the way void works, so could those 3 be changed to voidd. Thanks, MrKIA11 (talk) 12:45, 11 February 2008 (UTC)
 * ✅--Patrick (talk) 13:43, 11 February 2008 (UTC)

Stops at 36
When contained within another template, this seems to have a limit of 36. No archive links above that number are displayed. See Talk:Anarchism, talk:George W. Bush, Wikipedia talk:WikiProject Opera. They contain an experimental new talkheader template, talkheader4, which includes archive list. In talk:Anarchism, you can see that this is happening in other templates that make use of this template as well, since a separate archive box is also posted. Can anyone fill me in on what's going on?

PS I tested posting this template on its own without being contained in another template, and in that case it still doesn't display all archives, but it does go up to #39 instead of 36.  Equazcion •✗/C • 02:25, 30 Mar 2008 (UTC)


 * I've done some tests and it appears that the problem seems to come from having too many nested ParserFunctions. Rewriting the template to check if a given block of archives exists before linking to them might solve the problem; I'll have a go at this later. Tra (Talk) 12:02, 30 March 2008 (UTC)


 * It looks like you fixed it, Tra. Great job, thanks!  Equazcion •✗/C • 17:38, 30 Mar 2008 (UTC)

Redlink transclusions
Is there a reason why the template transcludes three non-existing template subpages which clutter up the "templates transcluded" list and look rather unsightly? I expect that it was (once upon a time) to enable the use of the parameters to be tracked, but is it now necessary? If not, removing them would tidy up countless edit screens. Happy‑melon 21:35, 11 April 2008 (UTC)
 * I was originally using them, so if no one else needs them, I don't mind removing them. MrKIA11 (talk) 23:03, 11 April 2008 (UTC)
 * Thanks - much tidier! Happy‑melon 12:49, 12 April 2008 (UTC)

Weird bug
Archive list is transcluded into Village pump/Archive header, which is then transcluded onto various pages, including Village pump (proposals)/Persistent proposals/Archive 1 and Village pump (proposals)/Persistent proposals/Archive 2. I just created Archive 2, and if you look at Archive 1, it lists both Archive 1 and Archive 2, but Archive 2 does not. I've cleared my cache, and it still shows that way. I don't even have an idea of where to start looking as to why it's doing this. Anyone smarter than I am with at least as much curiosity? (And template know-how?)--Aervanath lives in the Orphanage 19:30, 19 September 2008 (UTC)
 * They look fine to me. MrKIA11 (talk) 17:29, 20 September 2008 (UTC)
 * Hmm. They look fine to me, now, too. I guess the job queue hadn't caught up yet or something.  Oh well, problem solved.--Aervanath lives in the Orphanage 11:15, 21 September 2008 (UTC)

Clearer output if no archives exist
sudo

If placed on a discussion page with no archives, this template produces:

/1/

This is not particularly clear. It would be better to have it say something like:

no archives yet (create)

--Gurch (talk) 11:45, 29 December 2008 (UTC)


 * That code won't work. What happens is it checks if archive 1 exists, puts in the text 'no archives yet (create)' if archive 1 doesn't exist but then it runs the rest of the template as normal, resulting in an output of 'no archives yet (create)1'. I've put the code you gave in Template:Archive list/sandbox for further testing. The impact of this change should be fairly limited, however, since this template is mostly used through Talkheader and a few archival templates. Talkheader only displays the list if archive 1 exists and the archival templates would generally only be put on pages that have archives. Tra (Talk) 13:49, 29 December 2008 (UTC)
 * I've fixed the code in the sandbox page, but another concern I have is that this will cause one extra #ifexist call in nearly every transclusion of the template, and its benefits will hardly ever be seen. I'm not sure this is really necessary. Tra (Talk) 14:08, 29 December 2008 (UTC)
 * Regarding the first of those, "so what?"; the limit to #ifexist use is 100, which this template comes nowhere near. Regarding the second, the intention after this change is made is to modify to display it always, so that there's a link there to create an archive if one doesn't exist yet. This makes the archiving process easier and reduces the likelihood of archives being created in the wrong place, which often happens (in particular people miss the space between the numbers, or use a lowercase 'a', or call the first archive just "Archive") so that they have to be moved in order to work with templates such as this one that rely on the archives being named in the standard way. I also made, which contains just the archive part of , so that pages which don't need the whole header (which is most of them) can use that; I think the layout is better than that of  unless something else about the archives needs to be said, which is rare.
 * Yes, good points. ✅ Tra (Talk) 19:28, 29 December 2008 (UTC)

Link to archive index
How about checking for and adding a link to an archive index, e.g. "./Archive_Index"? —Apis (talk ) 02:54, 3 February 2009 (UTC)
 * In a lot of places where this could be useful, there would already be a link to the archive index. If this was implemented, to avoid duplicate links, we'd need to have a bot take out any existing links to the archive index. Tra (Talk) 14:48, 3 February 2009 (UTC)

Proper list markup
We should replace this template's (and its siblings') current, coma-separated markup with a proper list, styled to render horizontally, like lists in navboxes, thus:

1

2

3

4

5

6

by using either Flatlist or applying  and using wiki list markup, with asterisks. This will improve accessibility and more closely comply with HTML standards (strictly we should use hashes ("#") for an ordered list, but there's a dispute about how to display those horizontally). See also WP:HLIST. I'll add pointer to this discussion, from a page where the technicalities of how to do this are better understood. Andy Mabbett ( Pigsonthewing ); Andy's talk; Andy's edits 11:22, 15 November 2011 (UTC)

Limits
this is a great module! The only thing that seems to be missing is a way to make it display a max of one line or a max of ## archives from the end of the list... Currently, on Template:Teahouse questions navbox I'm using a workaround that is kind of hacky to accomplish my desired result and the code looks like:  Where it has to invoke itself again to get a count of the total archives and then perform a parser function to subtract nine (displays ten links) and start the list from there. Also, you'll see that I have a double non-breaking space as a sep -- I don't know if you coded in an easier way to do that like "none" or "space" or something else for those that don't know entity codes. Technical 13 (talk) 18:07, 3 July 2013 (UTC)

Yearly archive list
Could someone make yearly archive list into a wrapper for this template? It's basically the same thing with less functionality. —  Scott  •  talk  22:07, 2 February 2014 (UTC)

Prefix parameter doesn't accept empty value
Setting prefix as empty isn't working. Compare:

—  Scott  •  talk  22:16, 2 February 2014 (UTC)

Template-protected edit request on 13 February 2015
Could someone please wrap a around the "Template for move" tag. This will prevent the notice to be appended to every single instance were this template is used as is currently the case. Thank you,

Tvx1 (talk) 21:29, 13 February 2015 (UTC)
 * Red information icon with gradient background.svg Not done: Duplicate of the request at Template talk:Archive list long. -- Red rose64 (talk) 14:37, 14 February 2015 (UTC)

Merge in archive list long
Hi, the TfD to merge in archive list long closed as merge, so I'd like to move forward with that. I propose adding a parameter "format" to differentiate between the "long" format and this format, and to use the exponential search algorithm used in the lua module of archive list long to minimise the #ifexists parser function calls. Pinging for the Lua part of the proposal. Martijn Hoekstra (talk) 12:08, 21 February 2015 (UTC)

Template-protected edit request on 16 May 2015
I've made changes to the sandbox version of this module, in order to implement consensus reached in this TfD to merge Archive_list_long with Archive_list. These changes also obsolete Module:Archives. Please let me know if you have any questions. Essentially, I've added a function to detect whether the format should be long or short. If long, the format is output in table form to be identical to the to-be-deleted Archive_list_long. All testcases look fine. 1, 2, 3.

If you approve of the changes here, please migrate the sandbox version to mainspace. I will then make a request to migrate some changes on Archives, and the TfD mentioned above will be complete. Thanks!

Mamyles (talk) 15:40, 16 May 2015 (UTC)
 * ✅ &mdash; Martin (MSGJ · talk) 14:32, 18 May 2015 (UTC)

Someone check this please
I reapplied my buggy edit plus fix to Module:Archive list/sandbox. Please check, and apply if it seems good. Thanks. Anomie⚔ 04:36, 30 December 2017 (UTC)
 * , after a week of this lingering I don't think I'm the only one passing by this request. I'd love to help out but you don't give any clue as to what buggy-ness is being fixed, there's no testcases, and no clue which pages could be used in the template edit preview to show the effect of the change. There's no discussion here or at Template talk:Archive list to offer any clue either. Could you provide some more info to help us help you? Cabayi (talk) 11:51, 6 January 2018 (UTC)
 * I made the original edit so I could use this module to display the archives of my talk page, which are currently named from User talk:Anomie/Archives/2007 through User talk:Anomie/Archives/2017. With the current version of the module, it claims there are no archives because there is no User talk:Anomie/Archives/1, despite Archive list having a start to specifically say that 2007 is the first archive. Anomie⚔ 23:08, 6 January 2018 (UTC)
 * Anomie⚔ 23:09, 6 January 2018 (UTC)
 * So, using 's talk archives as the affected pages, if I edit Archive list and preview with User talk:Anomie, alter Archive list to use Module:Archive list/sandbox instead of Module:Archive list and preview again it should show the fix in action... Yep, looks good, doesn't affect previews of my talk (via User:Cabayi/arc) which has "standard" naming... Yes check.svg Done ~ Glad to be able to help out an editor whose tools we all rely on. -- Cabayi (talk) 13:00, 7 January 2018 (UTC)

Yearly archive list merger
Thoughts on merging Yearly archive list here? That would make essentially all templates that can auto detect sequential archives able to auto detect annual archives as well. The prize of this would be more ifexists though. Full disclosure that I haven't looked into implementation details. --Trialpears (talk) 22:12, 13 August 2021 (UTC)

Binary/exponential search?
Currently, the module finds the last archive by checking if each thousandth archive exists, and then each 200th, and then 50th, and tenth, before checking individual archives (I don't know if this search scheme has a proper name in any sense, so I'll just call it "stepwise"). This limits it to detecting around 400k (or is it 500k?) archives in ideal conditions, which should be sufficient for any talk page for the next few centuries. However, it isn't particularly efficient, and many numbers of archives will require extra #ifexist checks versus an exponential search. For example, a page with 29 archives currently requires 16 #ifexists with stepwise search (checking if archives exist as follows: 1000, 200, 50, 10, 20, 30, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 (there is no optimization to prevent the same archive number being rechecked in different steps, if I understand the code correctly)), whereas an exponential search would only require 10 (checking if archives exist as follows: 1, 2, 4, 8, 16, 32, 24, 28, 30, 29). For pages with fewer than 10 archives (which should be the vast majority of pages with archives), exponential search requires even fewer #ifexists, relative to stepwise. There's also the obvious point that exponential search would allow for many more archives to be checked (up to $2^{501}-1$, if there are no other expensive functions on the page), though by the time that actually becomes relevant, I'd imagine we'd have some better solution, or the limits wouldn't be as much of a concern (or both). As you can see, it takes until there are 10 archives before stepwise search can beat exponential search at all (and exponential again overtakes stepwise at 13 archives and maintains that lead up to 20 archives). Exponential search also only ever (very slowly) increases the number of required checks, whereas stepwise search requires a highly variable number of checks (and seeing its behavior in this table, I wouldn't be surprised if there are archive numbers far less than 400,000 where it requires too many #ifeq checks).

Exponential search was mentioned above in the context of merging in another module that used that method, but apparently nothing ever came of that mention. 「 ディノ 奴 千？！ 」☎ Dinoguy1000 15:44, 29 November 2021 (UTC)


 * I decided to go test my intuition for what the module is currently doing, by going through the first 200 pages that transclude the template, plus some bonus handpicked pages, replacing their contents with only  (plus anything required to generate the correct archive names), previewing, and checking the "Expensive parser function count" statistic in the "Parser profiling data" section at the bottom. My findings are presented in the following table; broadly speaking, my predictions match what the module is actually doing. The main surprises are cases of 0 archives (the current module somehow confirms this with only one expensive function, and I have no idea how) and multiples of 10 archives (which consistently use roughly double the predicted number of expensive functions, for the archive numbers I was able to find/test). My predictions also tend not to be correct for very large numbers of archives (in the hundreds and higher), though I figured that would be the case.
 * There is no special/hidden meaning behind the example pages listed here; for the most part they're just the first one I came across with that number of archives, though I replaced pages of contentious/controversial topics with more neutral pages where I could (contentious topics tend to draw more discussion, who'd have guessed).


 * 「 ディノ 奴 千？！ 」☎ Dinoguy1000 07:14, 5 December 2021 (UTC)

Edit request: Add param to leave the first cell blank 6 October 2022
Description of suggested change: For long archive lists (like Template:Arbitration_enforcement/Archive_navbox), it can be easier to read if the first column starts on a round number to guide the eye (plus, it just looks slightly nicer to me =])

Archive links usually start at 1 (not 0), so numbers in the first column are otherwise off by one from being multiples of the column count.

I made a copy in my Module:Sandbox and added a param to leave the first cell blank. I left it off by default to not disrupt existing behavior, since this seems to be transcluded in a lot of places, but this really meant for the smaller fraction of really long archive infoboxes that start to look like a heap of numbers.

See User:Mlkj/sandbox for an example with the WP:AE archives box. Here's what that looks like also on a small test table:

<p style="clear: both">Diff: (This mostly just adds a lines in a few different places, so I made a unidiff instead of fighting ) Mlkj (talk) 13:57, 6 October 2022 (UTC)
 * ✅ For future reference the best way to request complicated code changes is to make the change yourself to the module's sandbox (in this case Module:Archive list/sandbox) not produce a unified diff. * Pppery * <sub style="color:#800000">it has begun... 16:30, 8 October 2022 (UTC)
 * Noted, thank you. Mlkj (talk) 18:47, 8 October 2022 (UTC)