From 67cf202e643e4b4a03757371a46aacac0f8cb59c Mon Sep 17 00:00:00 2001
From: Nancy Nicoles <jn2@phpexercises.com>
Date: Tue, 4 Oct 2011 12:32:52 -0500
Subject: [PATCH] Issue #1296452 by jn2: Fixedhook_block_view_alter in block example.

---
 block_example/block_example.module |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/block_example/block_example.module b/block_example/block_example.module
index 26792ed..a1fad5b 100755
--- a/block_example/block_example.module
+++ b/block_example/block_example.module
@@ -200,27 +200,29 @@ function block_example_block_list_alter(&$blocks) {
  *
  * In addition, instead of hook_block_view_alter(), which is called for all
  * blocks, you can also use hook_block_view_MODULE_DELTA_alter() to alter a
- * specific block.
- *
- * We are going to uppercase the title of any block if the string "magic string"
- * is encountered in the content. If we were changing only our block using
- * hook_block_view_MODULE_DELTA_alter to do this, we would have used the
- * function:
+ * specific block. To change only our block using
+ * hook_block_view_MODULE_DELTA_alter, we would use the function:
  * block_example_block_view_block_example_example_configurable_text_alter()
  *
- * To demonstrate the effect of this hook, you can use the
- * 'configurable_text_string' block created by this module and add the
- * text 'magic string' into the configuration.
+ * We are going to uppercase the title of any block if the string "magic string"
+ * is encountered in the content, providing the content is a simple string. To
+ * demonstrate the effect of this hook, create a new block with a lower case
+ * title and the string 'magic string' included in the block body. The
+ * 'configurable_text_string' block created by this module will not work for
+ * this demonstration, as the content is returned as an array.
  */
 function block_example_block_view_alter(&$data, $block) {
-  // Verify the we have raw text content
+  // Verify the we have raw text content.
   if (!isset($data['content']) || !is_string($data['content'])) {
     return;
   }
-
   // If the content contains the string: 'magic string', uppercase the title.
   if (strstr($data['content'], 'magic string')) {
+    // This will work for blocks created programmatically if content is
+    // returned as a string.
     $data['subject'] = isset($data['subject']) ? drupal_strtoupper($data['subject']) : '';
+    // This works for blocks created in the UI.
+    $block->title = isset($block->title) ? drupal_strtoupper($block->title) : '';
   }
 }
 /**
-- 
1.7.1

