How do I print main_menu? I try to render a main menu but it doesn't render. My old Drupal 6 template try to upgrade Drupal 7 template.

I've render in page.tpl.php. 

&lt;?php if (isset($main_menu)) : ?&gt;
    &lt;?php print phptemplate_primary($main_menu); ?&gt;
  &lt;?php endif; ?&gt;


This is the code for phptemplate_primary().

function phptemplate_primary() {
  $output = '&lt;div id="primary-links-region"&gt;';
  $element = menu_tree(variable_get('menu_primary_links_source', 'primary-links'));
  $output .= drupal_render($element);
  $output .= '&lt;/div&gt;';
  return $output;
}


How do I resolve this problem?
You can do it both ways:


You can add menu block to your template - just like any other block (this method is the easiest).
If you need more customization, you can do it in template:


page.tpl.php

&lt;?php if ($primary_nav): print $primary_nav; endif; ?&gt;


template.php

if (isset($variables['main_menu'])) {
  $variables['primary_nav'] = theme('links__system_main_menu', array(
    'links' =&gt; $variables['main_menu'],
    'attributes' =&gt; array(
      'class' =&gt; array('links', 'inline', 'main-menu'),
    ),
    'heading' =&gt; array(
      'text' =&gt; t('Main menu'),
      'level' =&gt; 'h2',
      'class' =&gt; array('element-invisible'),
    )
  ));
}
else {
  $variables['primary_nav'] = FALSE;
}