function related_blog_block_view in Util 6.3
Same name and namespace in other branches
- 7 contribs/related_blog/related_blog.module \related_blog_block_view()
 
Function for related_blog_block(op = 'view').
1 call to related_blog_block_view()
- related_blog_block in contribs/
related_blog/ related_blog.module  - Implements hook_block();
 
File
- contribs/
related_blog/ related_blog.module, line 44  - Provides block to show blog of node's author.
 
Code
function related_blog_block_view($delta = 0) {
  $block = array();
  switch ($delta) {
    case 'related_blog':
      // Make sure it makes sense to show this.
      // That is, not on node add/edit, etc.
      $extra = arg(2);
      if ($extra) {
        return $block;
      }
      // Get configured content types.
      $types = variable_get('related_blog_types', array());
      // Get the currently displayed node.
      $node = menu_get_object();
      // Make sure it's one of our types.
      if (in_array($node->type, $types)) {
        $account = user_load(array(
          'uid' => $node->uid,
        ));
        // Get the current title (note that this is already sanitized).
        $title = drupal_get_title();
        // Make sure the blog code is loaded.
        module_load_include('inc', 'blog', 'blog.pages');
        // Call the blog page code.
        $block['content'] = blog_page_user($account);
        // Restore the title as blog_page_user will screw it up.
        drupal_set_title($title);
      }
      break;
  }
  return $block;
}