mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Support for legacy installations for the date based blog entry listing
This commit is contained in:
parent
eef7d57b80
commit
4522830ef8
@ -162,9 +162,27 @@ class BlogTree extends Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($date) {
|
if($date) {
|
||||||
if(strpos($date, '-')) {
|
/**
|
||||||
$year = (int) substr($date, 0, strpos($date, '-'));
|
* Some systems still use the / seperator for date presentation
|
||||||
$month = (int) substr($date, strpos($date, '-') + 1);
|
* In order to cater for them, I have implemented this quick way of using either one based on scenario
|
||||||
|
* @author JA Clarke
|
||||||
|
* @since 2011/05/05 SAST
|
||||||
|
*/
|
||||||
|
if( strpos($date, '-') ) $seperator = '-';
|
||||||
|
elseif( strpos($date, '/') ) $seperator = '/';
|
||||||
|
|
||||||
|
if(isset($seperator) && !empty($seperator)) {
|
||||||
|
/**
|
||||||
|
* This is a better implementation of getting the $year and $month fields
|
||||||
|
* substr() is fine, but it is major overhead
|
||||||
|
* The 2 in the explode argument will tell it to only create 2 elements
|
||||||
|
* i.e. in this instance the $year and $month fields respectively
|
||||||
|
* @author JA Clarke
|
||||||
|
* @since 2011/05/05 SAST
|
||||||
|
*/
|
||||||
|
list($year,$month) = explode( $seperator, $date, 2);
|
||||||
|
$year = (int)$year;
|
||||||
|
$month = (int)$month;
|
||||||
|
|
||||||
if($year && $month) {
|
if($year && $month) {
|
||||||
if(method_exists(DB::getConn(), 'formattedDatetimeClause')) {
|
if(method_exists(DB::getConn(), 'formattedDatetimeClause')) {
|
||||||
|
Loading…
Reference in New Issue
Block a user