You are here

function _insert_block_substitute_tags in Insert Block 5

Same name and namespace in other branches
  1. 6 insert_block.module \_insert_block_substitute_tags()
1 call to _insert_block_substitute_tags()
insert_block_nodeapi in ./insert_block.module

File

./insert_block.module, line 52

Code

function _insert_block_substitute_tags(&$node, $field) {
  if (preg_match_all("/\\[block:([^=\\]]+)=?([^\\]]*)?\\]/i", $node->{$field}, $match)) {
    foreach ($match[2] as $key => $value) {
      $module = $match[1][$key];
      $delta = $match[2][$key];
      $block = module_invoke($module, 'block', 'view', $delta);
      $mtch[] = $match[0][$key];
      $repl[] = theme('insert_block_block', $block);
    }
    return str_replace($mtch, $repl, $node->{$field});
  }
  return $node->{$field};
}