I am working on a site that I didn't build, and have come across a problem with the sort order of the blog archives. (see screenshot) It is sorting the years as 2011, 2010, 2012, which makes no sense to me at all.
The months are also sorted wrong, apparently by ignoring the leading zero, so they are: 1, 10, 11, 12, 2, 3, etc. (Jan, Oct, Nov, Dec, Feb, Mar.)
The date that is being sorted is a TV
entryDate with Input Type: Date and Widget: Unixtime.
The site is Evo 1.0.5, Php 5.2.13
The snippet that creates the archive is:
<?php
$sql = "SELECT id FROM site_content sc WHERE sc.template = 7";
$rs = $modx->db->query($sql);
$links = array();
while($row = mysql_fetch_array($rs)){
$id = $row['id'];
$tvs = $modx->getTemplateVarOutput("*", $id);
$year = date("Y", $tvs['entryDate']);
$month = (int)date("n", $tvs['entryDate']);
$monthName = date("F", $tvs['entryDate']);
$links[$year][$month] = "<a href='[~4~]?&reflect_month=$month&reflect_year=$year'>" . $monthName . "</a>";
}
foreach($links as $year => $months){
sort($months);
echo "<ul class=''><li><a href='[~4~]?&reflect_year=$year'>" . $year . "</a><ul class='reflect_months'>";
foreach($months as $month){
echo "<li>" . $month . "</li>";
}
echo "</ul></li></ul>";
}
?>
The manager is set to display dates as dd/mm/YYYY. I checked and this is how the dates for this TV are stored in the DB. Don't know if that would make a difference.
[ed. note: lucy last edited this post 14 years, 7 months ago.]