From 1035341ac73644bddf99c5a3cd01f4c53d0f34d1 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 18 Mar 2010 06:26:36 +0000 Subject: [PATCH] - Patch #700704 by sobi3ch, Rob Loach, andypost: added ability to change the amount of blog posts listed. --- modules/blog/blog.module | 26 +++++++++++++++++++++++++- modules/blog/blog.test | 5 +++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 9e7d83b49e5..354698af140 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -183,6 +183,30 @@ function blog_block_info() { return $block; } +/** + * Implements hook_block_configure(). + */ +function blog_block_configure($delta = '') { + if ($delta == 'recent') { + $form['blog_block_count'] = array( + '#type' => 'select', + '#title' => t('Number of recent blog posts to display'), + '#default_value' => variable_get('blog_block_count', 10), + '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)), + ); + return $form; + } +} + +/** + * Implements hook_block_save(). + */ +function blog_block_save($delta = '', $edit = array()) { + if ($delta == 'recent') { + variable_set('blog_block_count', $edit['blog_block_count']); + } +} + /** * Implements hook_block_view(). * @@ -197,7 +221,7 @@ function blog_block_view($delta = '') { ->condition('type', 'blog') ->condition('status', 1) ->orderBy('created', 'DESC') - ->range(0, 10) + ->range(0, variable_get('blog_block_count', 10)) ->addTag('node_access') ->execute(); diff --git a/modules/blog/blog.test b/modules/blog/blog.test index f640cfef12d..e6866b9850e 100644 --- a/modules/blog/blog.test +++ b/modules/blog/blog.test @@ -65,6 +65,11 @@ class BlogTestCase extends DrupalWebTestCase { $edit['blog_recent[region]'] = 'sidebar_second'; $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); $this->assertResponse(200); + // Verify ability to change number of recent blog posts in block. + $edit = array(); + $edit['blog_block_count'] = 5; + $this->drupalPost('admin/structure/block/manage/blog/recent/configure', $edit, t('Save block')); + $this->assertEqual(variable_get('blog_block_count', 10), 5, t('Number of recent blog posts changed.')); // Do basic tests for each user. $this->doBasicTests($this->any_user, TRUE);