How to implement menu in footer blcok I need a (D7) block print the main menu in the footer; It's not clear to me how the pieces fit together:

We implement block_info, block_view, a pre-process function and a template.

function MODULE_NAME_block_info() {
  $blocks['my-footer-menu'] = array(
    'info' =&gt; t('My Footer'),
  );  
  return $blocks;
}

function MODULE_NAME_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    case 'my-footer-menu'
     $tree = menu_tree_page_data('main-menu');
     $block = array( 'subject' =&gt; t('My Footer'),
                  'content' =&gt; theme('my-footer-menu', $tree),
      );
    break;
 }
return $block; 
}


function MODULE_NAME_theme() {
  return array(
    'my_footer_menu' =&gt; array(
    'template' =&gt; 'my-footer-menu',
    'variables' =&gt; array('tree' =&gt; NULL),
  ),
);
}

function template_preprocess_my_footer_menu(&amp;$variables) {
  $variables['tree'] = menu_tree_all_data('main-menu'); 
}

&lt;?php
  for ($i = 0; $i &lt; count($tree); $i++) {
    $menu = each($tree);
     if ($menu) {
        $link = array( '#theme' =&gt; 'link', 
                'title' =&gt; $menu[1]['link']['link_title'],
               'href' =&gt; $menu[1]['link']['link_path']);
          print '&lt;a href="'  . $link['href'] . '"&gt;' . $link['title'] . '&lt;/a&gt;';
        //  $output = theme( 'links', $link);  //this isn't right
        //  print $output;    //returns an empty string;
        }
      }
 ?&gt;


The above gets the top level menu items on the page, but it's not clear how to get to the children of each menu item.   Sorry if it seems a bit muddled, just trying to cut my way through the weeds here.
You can create all of the code yourself, but you could also use the menu block module instead and save yourself a lot of work.