Can I use hook_block_info() in a theme? In Drupal 7, can I use hook_block_info() in a theme?

I would like my theme to create a block (which would contain dynamic content). This will allow the user to move it around where he wants to, or simply hide it.

Is this the way to go?

/**
 * Implements hook_block_info() 
 */
function mytemplate_block_info()
{
  $blocks['mytemplate-block'] = array(
    'info' =&gt; t('TemplateBlock'),
    'weight' =&gt; -100,
    'status' =&gt; 1,
    'region' =&gt; 'content',
    'visibility' =&gt; BLOCK_VISIBILITY_LISTED,
    'pages' =&gt; '&lt;front&gt;',
  );

  return $blocks;
}

/**
 * Implements hook_block_view() 
 */
function mytemplate_block_view($delta = '')
{
  $block = array();

  switch ($delta) {
    case 'mytemplate-block':
      $block['content'] = 'some custom html';
    break;

  }

  return $block;
}
I'm afraid you can't, no, it has to be in a module.

The array of blocks is built up in _block_render_blocks() using the module_invoke() function which, as its name suggests, only invoke hooks for modules and not themes.

If you haven't written a custom module before don't be afraid to get stuck in its pretty easy. I'd highly recommend the Module Developer's Guide which will tell you everything you need to know.