Template talk:News

From Organic Design

Category listing

If one of you clever folks could add a suitable piped link to "Category:News" in the template, showing the date in ISO format or similar, all of the items could list in date order in the category, instead of alphanumerically by "NZ English" date format. Robin Patterson 06:50, 3 September 2011 (PDT)

Thanks for the suggestion, I've reverted the manual categorisations you did as there's too many to do by hand, I could get a robot to do it some time, but I'd prefer to have an automatic way as you suggest in Template:News, but it's actually quite difficult and I haven't been able to figure out a way to do it yet. The reason it's so hard is because there's no way for a template to obtain the name of the article that's transcluding it - I can't even add a magic word for it because it's not readily available from the MediaWiki PHP code either. --nad 15:36, 3 September 2011 (PDT)
Have you tried using something related to the relevant-looking item on 11 June 2007‎? "Date of first edit". Seems to me that if you can dig that info out of a page to arrange pages in a defined way you may be able to put the info in a piped link that orders the category. That's what prompted my edit summary on 11 June 2007‎. Robin Patterson 17:46, 3 September 2011 (PDT)
The categorisation statement needs to be in Template:News and in that scope there is no way to access the name of the parent article into which it is being transcluded (which are the news items needing to be categorised). The 11 June 2007 article explains a DPL query which doesn't help in this situation. If I could access the title of the parent article I would be able to add a statement in Template:News like this: [[Category:News|{{#time:Ymd|PARENT}}]] where PARENT is the news item title the template is being used within such as "2 September 2007" etc. :--nad 18:23, 3 September 2011 (PDT)
Just realised one thing I neglected to remember about the way MediaWiki works is that the category links are only updated for an article when it is saved, so in that case it's guaranteed that the {{PAGENAME}} variable will be correct (i.e. the name of the news item such as "16 March 2006" rather than the "News" page). This means I could achieve the sort-key by testing if the article title is a valid date and then using the #time parser function to convert that title to yyyymmdd format. I've added this to the News template (see diff). It's working, but unfortunately gets broken if the rebuildLinks.php maintenance script is run since that script doesn't expand wikitext. --nad 21:56, 5 September 2011 (PDT)