--- nodeblock.module 2009-03-31 23:12:10.000000000 -0400 +++ nodeblock.module 2009-04-30 15:11:48.000000000 -0400 @@ -102,6 +102,11 @@ function nodeblock_block($op = 'list', $ elseif ($op == 'view') { $node = node_load($delta); + // If CCK is enabled, set the build mode to the region. + if (module_exists('content')) { + $node->build_mode = _nodeblock_block_region($delta); + } + // if the node type is translatable, try to load the node with the appropriate // language from the translation set. if (module_exists('translation') && translation_supported_type($node->type)) { @@ -186,4 +191,46 @@ function nodeblock_preprocess_node(&$var */ function nodeblock_theme_registry_alter(&$registry) { array_unshift($registry['node']['theme paths'], drupal_get_path('module', 'nodeblock')); +} + +/** + * Implementations of hook_content_build_modes + * on behalf of core modules. + * + * @see node_content_build_modes() in content.module + * + * @return + * An array describing the build modes used by the module. + * They are grouped by secondary tabs on CCK's 'Display fields' screens. + */ +function nodeblock_content_build_modes() { + global $theme; + init_theme(); + + $build_modes = array(); + foreach (system_region_list($theme) as $region => $title) { + $build_modes[$region] = array('title' => $title, 'views_style' => TRUE); + } + + return array( + 'nodeblock' => array( + 'title' => t('Block'), + 'build modes' => $build_modes, + ), + ); +} + +/** + * Returns the region the block is being viewed in. + * + * @param $delta + * The $delta (or) $nid of the block + * + * @return + * The region for the block. + */ +function _nodeblock_block_region($delta) { + global $theme_key; + + return db_result(db_query("SELECT region FROM {blocks} WHERE module = 'nodeblock' AND delta = '%s' AND theme ='%s'", $delta, $theme_key)); } \ No newline at end of file