Loading...
 
Skip to main content

Features / Usability


last_blog_posts - how to show only entries of last 2 months ?

Hi,

how do I have to modifiy last_blog_posts to show only recent blog entries, lets say from the last 2 weeks.
Is it something that can be achieved by the "Parameter" option in the configuration ?
Or some hardcoding required, if so - where are the MySQL statements that have to be changed ?

Thx...
Martin

So, list_posts in tikilib.php might be a place to start.
But I cant figure out the SQL statement correctly.

Copy to clipboard
$query = "select * from `tiki_blog_posts` $mid order by ".$this->convert_sortmode($sort_mode);


should be it, but how to calc the date difference ?


If I use someting like

Copy to clipboard
mysql> SELECT something FROM tbl_name -> WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY)


fitting it into $mid does nothing at all.

Maybe list_posts isn´t the place to go ?


...

Ok, solved.
Just in case someone else needs to do it:

Simply modify list_posts in libs/tikilib.php as follows:

Copy to clipboard
$mid = 'WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) < = FROM_UNIXTIME(created)



The FROM_UNIXTIME wrapper is needed, because tikiwiki doesn´t make use of date/datetime fieldtypes.
CURDATE( ) gives you the current date and time as unix timestamp, interval defines until when the select should go back.