1

I have created a custom template and i don not want the default menu structure of drupal 7.So I thought of creating a custom structure for this.In my custom theme page.tpl page i have called the the following theme function.

<?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu'))); ?>

I have created a new custom template.php file in the same theme directory where the page.tpl.php resides and defined the following function

function mytheme_links__system_main_menu($variables) {
  $html = "<div>\n";
  $html .= "  <ul>\n"; 

  foreach ($variables['links'] as $link) {
    $html .= "<li>".l($link['title'], $link['path'], $link)."</li>";
  }

  $html .= "  </ul>\n";
  $html .= "</div>\n";

  return $html;
}

but tthis function that is being included in the tempkate.php file does not seem to be called for some reason.Could someone please help me as o why the mytheme_links__system_main_menu is not called.Thanks in advance..

  • Have you cleared your caches/rebuilt your theme registry since adding this? – Jimajamma Mar 22 '14 at 15:30
  • Also, I am not sure what you are saying about creating a new custom template.php file in the same theme directory as the page.tpl.php resides, but most themes will only look for one template.php file and that is in the toplevel directory of the theme, so this function (named appropriately) should probably go in there.... – Jimajamma Mar 22 '14 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.