You may use [block:module=delta] tags to display the contents of block delta for module module. To discover module names and deltas, visit admin/build/block and hover over a block\'s configure link and look in your browser\'s status bar. The last "word" you see is the name of the module and the number following that is the delta. If you leave off the delta in an Insert Block tag, the default delta will be used.'); } else { return t('You may use [block:module=delta] tags to display the contents of block delta for module module.', array("@insert_block_help" => url("filter/tips/$format", array('fragment' => 'filter-insert_block')))); } } /** * Implementation of hook_help(). */ function insert_block_help($section = 'admin/help#insert_block', $args = array()) { $output = ''; switch ($section) { case 'admin/help#insert_block': return t('

Use special tags to insert the contents of a block into a node.

You may use [block:module=delta] tags in the body of a node or anywhere that Drupal\'s filter system runs to display the contents of block delta for module module.

To discover module names and deltas, visit admin/build/block and hover over a block\'s configure link and look in your browser\'s status bar. The last "word" you see is the name of the module and the number following that is the delta. If you leave off the delta in an Insert Block tag, the default delta will be used.

'); } } /** * Implementation of hook_filter(). */ function insert_block_filter($op, $delta = 0, $format = -1, $text = '') { // The "list" operation provides the module an opportunity to declare both how // many filters it defines and a human-readable name for each filter. Note that // the returned name should be passed through t() for translation. if ($op == 'list') { return array( 0 => t('insert block filter')); } // go ahead and set this up for multiple filters, though I doubt we'll use it switch ($delta) { case 0: switch ($op) { case 'description': return t('Inserts the contents of a block into a node using [block:module=delta] tags.'); case 'prepare': return $text; case 'process': return _insert_block_substitute_tags($text); case 'no cache': return TRUE; } break; } } function _insert_block_substitute_tags($text) { if (preg_match_all("/\[block:([^=\\]]+)=?([^\\]]*)?\]/i", $text, $match)) { foreach ($match[2] as $key => $value) { $raw_tags[] = $match[0][$key]; $module = $match[1][$key]; $delta = $match[2][$key]; $block = module_invoke($module, 'block', 'view', $delta); $repl[] = theme('insert_block_block', $block); } return str_replace($raw_tags, $repl, $text); } return $text; } /** * Implementation of hook_theme(). */ function insert_block_theme() { $themes = array( 'insert_block_block' => array( 'arguments' => array('block'), ), ); return $themes; } /** * Format an included block. * * Gets passed the block array to be formatted. By default it includes * the block subject, if any, and the block's content. * * @ingroup themeable */ function theme_insert_block_block($block) { $content = ''; if (!empty($block['subject'])) { $content .= '

'. $block['subject'] .'

'; } if (!empty($block['content'])) { $content .= $block['content']; } return $content; }