1 austriaco Sep 11, 2007 18:37
3 austriaco Sep 23, 2007 21:32
Is there anybody working on this? I might give it a shot, if nobody is working on that, on my absolutely nothing-else-to-do moments.
4 austriaco Sep 23, 2007 23:58
Here is a working patch against CVS that solves the post ordering problem in Archives plugin. It should also take into account descending or ascending order for all the other modes (I've only tested with 'postbypost'):
diff -ubrxCVS b2evolution/blogs/plugins/_archives.plugin.php /home/lnieves/liberal/315web/plugins/_archives.plugin.php
--- b2evolution/blogs/plugins/_archives.plugin.php 2007-09-23 23:41:10.000000000 +0200
+++ /home/lnieves/liberal/315web/plugins/_archives.plugin.php 2007-09-23 23:28:20.000000000 +0200
@@ -83,6 +83,7 @@
* - 'title' : (Default: T_('Archives'))
* - 'mode' : 'monthly'|'daily'|'weekly'|'postbypost' (Default: conf.)
* - 'sort_order' : 'date'|'title' (Default: date - used only if the mode is 'postbypost')
+ * - 'orderdir' : 'DESC'|'ASC' (Default: from Blog settings)
* - 'link_type' : 'canonic'|'context' (default: canonic)
* - 'context_isolation' : what params need override when changing date/range (Default: 'm,w,p,title,unit,dstart' )
* - 'form' : true|false (default: false)
@@ -137,6 +138,13 @@
elseif(!isset($params['sort_order']) || $params['sort_order'] == '') {
$params['sort_order'] = 'date';
}
+ //Order direction: DESC or ASC. Default comes from the Blog settings:
+ if(!isset($params['orderdir'])) {
+ $params['orderdir'] = $Blog->get_setting('orderdir');
+ }
+ elseif(isset($params['orderdir']) && ($params['orderdir'] != 'DESC' || $params['orderdir'] != 'ASC') ) {
+ $params['oderdir'] = $Blog->get_setting('orderdir');
+ }
// Link type:
if(!isset($params['link_type'])) $params['link_type'] = 'canonic';
@@ -167,7 +175,7 @@
$params['day_date_format'] = $dateformat;
}
- $ArchiveList = & new ArchiveList( $params['mode'], $params['limit'], $params['sort_order'], ($params['link_type'] == 'context'),
+ $ArchiveList = & new ArchiveList( $params['mode'], $params['limit'], $params['sort_order'], $params['orderdir'], ($params['link_type'] == 'context'),
$this->dbtable, $this->dbprefix, $this->dbIDname );
echo $params['block_start'];
@@ -331,6 +339,7 @@
$archive_mode = 'monthly',
$limit = 100,
$sort_order = 'date',
+ $orderdir = 'DESC', /* Provide for reverse-date sort of post-by-post archives */
$preserve_context = false,
$dbtable = 'T_items__item',
$dbprefix = 'post_',
@@ -347,6 +356,7 @@
$this->dbprefix = $dbprefix;
$this->dbIDname = $dbIDname;
$this->archive_mode = $archive_mode;
+ $this->orderdir = $orderdir;
/*
@@ -406,7 +416,7 @@
.$this->from
.$this->where.'
GROUP BY year, month
- ORDER BY year DESC, month DESC';
+ ORDER BY year '.$this->orderdir.' , month '.$this->orderdir;
break;
case 'daily':
@@ -417,7 +427,9 @@
.$this->from
.$this->where.'
GROUP BY year, month, day
- ORDER BY year DESC, month DESC, day DESC';
+ ORDER BY year '.$this->orderdir.
+ ' , month '.$this->orderdir.
+ ' , day '.$this->orderdir;
break;
case 'weekly':
@@ -428,7 +440,8 @@
.$this->from
.$this->where.'
GROUP BY year, week
- ORDER BY year DESC, week DESC';
+ ORDER BY year '.$this->orderdir.
+ ' , week '.$this->orderdir;
break;
case 'postbypost':
@@ -440,10 +453,10 @@
.$this->group_by.'
ORDER BY ';
if($sort_order == 'title'){
- $sql .= $this->dbprefix.'title ASC';
+ $sql .= $this->dbprefix.'title '.$this->orderdir;
}
else if($sort_order == 'date'){
- $sql .= $this->dbprefix.'datestart DESC';
+ $sql .= $this->dbprefix.'datestart '.$this->orderdir;
}
}
Additional testing for different archiving modes (I have only tested with postbypost) would be necessary to see if this does what I think it should do.
Have fun!
Yes the archives widget needs some serious rewriting.