0

I've got problem with making main-menu wrapped in element. I've tried:

  1. Using hooks in template.php like:

    function koko_menu_link_main_menu($variables) { /* For block override */
    $output = '<nav>';
          foreach ($variables['links'] as $link) {
            $output .= l($link['title'], $link['href'], $link);
      }
      $output .= '</nav>';
      return $output;
    }
    
    
    function koko_links__system_main_menu($variables) {
      $output = '<nav>';
    foreach ($variables['links'] as $link) {
      $output .= l($link['title'], $link['href'], $link);
    }
      $output .= '</nav>';
        return $output;
    }
    

    Using preprocesss/block.preprocess.inc:

      switch ($variables['block']->module) {
        case 'system':
          switch ($variables['block']->delta) {
            case 'help':
            case 'powered-by':
              break;
    
          case 'main':
              // Use a template with no wrapper for the page's main content.
              $variables['theme_hook_suggestions'][] = 'block__minimal';
              break;
    
          default:
              // Any other "system" block is a menu block and should use
              // block--nav.tpl.php
              $variables['theme_hook_suggestions'][] = 'block__nav';
              break;
          }
          break;
    
          case 'menu':
          case 'menu_block':
          // Use block--nav.tpl.php template.
          $variables['theme_hook_suggestions'][] = 'block__nav';
          break;
      }
    
    
    case 'main':
      // Use a template with no wrapper for the page's main content.
      $variables['theme_hook_suggestions'][] = 'block__minimal';
      break;
    
    default:
      // Any other "system" block is a menu block and should use
      // block--nav.tpl.php
      $variables['theme_hook_suggestions'][] = 'block__nav';
      break;
     }
     break;
    
    case 'menu':
    case 'menu_block':
        // Use block--nav.tpl.php template.
         $variables['theme_hook_suggestions'][] = 'block__nav';
         break;
       }
    

That contains. block--nav.tpl.php

    <nav<?php print $attributes; ?>>
      <?php print render($title_prefix); ?>
      <?php print render($title_suffix); ?>
      <?php print $content; ?>
    </nav>

Still nothing happends. Main-menu is not wrapped in anything different than: <div class="content">.

0

Did you read this and this posts? I thinks it's not so difficult to achieve this:

function MYTHEME_links__system_main_menu($variables) {
  $html = "<div>\n";
  $html .= "  <nav>\n";
  foreach ($variables['links'] as $link) {
    $html .= "<li>".l($link['title'], $link['path'], $link)."</li>";
  }
  $html .= "  </nav>\n";
  $html .= "</div>\n";
  return $html;
}
  • Nothing happends. Even after copy&cut of your code (with changing MYTHEME) nothing happends. Cache cleared and CRON updated. – maszynka Feb 11 '14 at 13:40

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.