$content variable in block.tpl.php I have customized a block.tpl.php file and I want to access the individual fields in it. But when I put print render($content['field_name']) in my code nothing is printed out. And also print_r(array_keys($content)) doesn't give anything.

I have used the above codes in my page.tpl and node.tpl files successfully before.

I'm on D7.

So is it done somehow differently in block template? What's going on?
If you have a look at the code for the original block.tpl.php file, $content doesn't actually get run through render(), as it's already been rendered to a string.

If you want to alter the block content while it's still in a structured array you should use a hook_block_view_alter() implementation in a custom module. This is the example from the docs page:

function hook_block_view_alter(&amp;$data, $block) {
  // Remove the contextual links on all blocks that provide them.
  if (is_array($data['content']) &amp;&amp; isset($data['content']['#contextual_links'])) {
    unset($data['content']['#contextual_links']);
  }
  // Add a theme wrapper function defined by the current module to all blocks
  // provided by the "somemodule" module.
  if (is_array($data['content']) &amp;&amp; $block-&gt;module == 'somemodule') {
    $data['content']['#theme_wrappers'][] = 'mymodule_special_block';
  }
}


How successful you'll be using this method depends on how well the modules that provide the blocks respect render arrays. If an implementation of hook_block() by a particular module flattens the block content to a string before it is made alterable, then you'll have to make the changes somewhere else in the process (probably using a theme preprocess/override).