Commit 334dbbbe authored by Lorena Paoletti's avatar Lorena Paoletti Committed by Richard Mansfield
Browse files

Recent Blog Posts to limit the number of posts to be displayed (Bug #547967)


Signed-off-by: default avatarLorena Paoletti <lorena.paoletti@gmail.com>
parent ef2bf4d6
......@@ -28,7 +28,8 @@
defined('INTERNAL') || die();
$string['title'] = 'Recent Blog Posts';
$string['description'] = 'Display the 10 most recent blog posts';
$string['description'] = 'Display the most recent blog posts';
$string['itemstoshow'] = 'Items to show';
$string['postedin'] = 'in';
$string['postedon'] = 'on';
......
......@@ -46,6 +46,8 @@ class PluginBlocktypeRecentposts extends PluginBlocktype {
$configdata = $instance->get('configdata');
$result = '';
isset($configdata['count']) ? $configdata['count'] : 10;
if (!empty($configdata['artefactids'])) {
$artefactids = implode(', ', array_map('db_quote', $configdata['artefactids']));
if (!$mostrecent = get_records_sql_array(
......@@ -57,7 +59,7 @@ class PluginBlocktypeRecentposts extends PluginBlocktype {
AND a.parent IN ( ' . $artefactids . ' )
AND a.owner = (SELECT "owner" from {view} WHERE id = ?)
ORDER BY a.ctime DESC
LIMIT 10', array($instance->get('view')))) {
LIMIT ' . $configdata['count'], array($instance->get('view')))) {
$mostrecent = array();
}
// format the dates
......@@ -80,7 +82,15 @@ class PluginBlocktypeRecentposts extends PluginBlocktype {
public static function instance_config_form($instance) {
safe_require('artefact', 'blog');
$configdata = $instance->get('configdata');
$elements = array(self::artefactchooser_element((isset($configdata['artefactids'])) ? $configdata['artefactids'] : null));
$elements = array(self::artefactchooser_element((isset($configdata['artefactids'])) ? $configdata['artefactids'] : null),
'count' => array(
'type' => 'text',
'title' => get_string('itemstoshow', 'blocktype.blog/recentposts'),
'defaultvalue' => isset($configdata['count']) ? $configdata['count'] : 10,
'size' => 3,
),
);
return $elements;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment