Commit 1035341a authored by Dries's avatar Dries

- Patch #700704 by sobi3ch, Rob Loach, andypost: added ability to change the...

- Patch #700704 by sobi3ch, Rob Loach, andypost: added ability to change the amount of blog posts listed.
parent 44745517
...@@ -183,6 +183,30 @@ function blog_block_info() { ...@@ -183,6 +183,30 @@ function blog_block_info() {
return $block; 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(). * Implements hook_block_view().
* *
...@@ -197,7 +221,7 @@ function blog_block_view($delta = '') { ...@@ -197,7 +221,7 @@ function blog_block_view($delta = '') {
->condition('type', 'blog') ->condition('type', 'blog')
->condition('status', 1) ->condition('status', 1)
->orderBy('created', 'DESC') ->orderBy('created', 'DESC')
->range(0, 10) ->range(0, variable_get('blog_block_count', 10))
->addTag('node_access') ->addTag('node_access')
->execute(); ->execute();
......
...@@ -65,6 +65,11 @@ class BlogTestCase extends DrupalWebTestCase { ...@@ -65,6 +65,11 @@ class BlogTestCase extends DrupalWebTestCase {
$edit['blog_recent[region]'] = 'sidebar_second'; $edit['blog_recent[region]'] = 'sidebar_second';
$this->drupalPost('admin/structure/block', $edit, t('Save blocks')); $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
$this->assertResponse(200); $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. // Do basic tests for each user.
$this->doBasicTests($this->any_user, TRUE); $this->doBasicTests($this->any_user, TRUE);
......
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