- Patch #700704 by sobi3ch, Rob Loach, andypost: added ability to change the amount of blog posts listed.

merge-requests/26/head
Dries Buytaert 2010-03-18 06:26:36 +00:00
parent 4474551713
commit 1035341ac7
2 changed files with 30 additions and 1 deletions

View File

@ -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();

View File

@ -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);