summaryrefslogtreecommitdiff
path: root/modules/blog
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-03-18 06:26:36 +0000
committerDries Buytaert <dries@buytaert.net>2010-03-18 06:26:36 +0000
commit1035341ac73644bddf99c5a3cd01f4c53d0f34d1 (patch)
tree4f6adb513b159cbb04ee4eb694836419a6ce32b9 /modules/blog
parent4474551713144a5176f784ac9a8348741d3c363c (diff)
downloadbrdo-1035341ac73644bddf99c5a3cd01f4c53d0f34d1.tar.gz
brdo-1035341ac73644bddf99c5a3cd01f4c53d0f34d1.tar.bz2
- Patch #700704 by sobi3ch, Rob Loach, andypost: added ability to change the amount of blog posts listed.
Diffstat (limited to 'modules/blog')
-rw-r--r--modules/blog/blog.module26
-rw-r--r--modules/blog/blog.test5
2 files changed, 30 insertions, 1 deletions
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index 9e7d83b49..354698af1 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -184,6 +184,30 @@ function blog_block_info() {
}
/**
+ * 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().
*
* Displays the most recent 10 blog titles.
@@ -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 f640cfef1..e6866b985 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);