You are here

webform_block.module in Webform blocks 7

File

webform_block.module
View source
<?php

/**
 * Implements hook_block_info().
 */
function webform_block_block_info() {
  $blocks['current'] = array(
    'info' => t('Current webform block'),
    'cache' => DRUPAL_NO_CACHE,
  );
  return $blocks;
}

/**
 * Implements hook_block_view().
 */
function webform_block_block_view($delta = '') {
  $node = menu_get_object();
  if (!isset($node->nid)) {
    return;
  }

  // We don't want to manipulate the actual node content. So we backup the
  // original content and insert it again once we're done. Why is the renderable
  // content stored as part of the node object in the first place?
  $original_content =& $node->content;
  unset($node->content);
  $node->content = array();
  webform_node_view($node, 'form');
  $block['subject'] = NULL;
  $block['content'] = isset($node->content['webform']) ? $node->content['webform'] : NULL;
  $node->content =& $original_content;
  return $block;
}

Functions