V
V
Vlad1712015-09-11 23:47:32
Drupal
Vlad171, 2015-09-11 23:47:32

How to work with menu_tree and menu_link in Drupal?

Dear drupalists! Boiling brain. Nothing works! The bottom line is this: I started learning Drupal. I decided to create a theme from scratch, and at the same time figure out what's what in this cms. The first thing I came across was the need to customize the menu. You can, of course, stupidly display it through a block with your markup, but I want to be able to work with it in normal mode through the admin panel. I read on the Internet how to do it, people on toster advised: redefine the functions menu_tree (wrapper for the entire menu) and menu_link (wrapper for the menu item). The problem is that nothing changes at all. Fragment where the region for the menu is displayed (page.tpl.php):

<body>
<div id="main">
    <div id="header"></div>
    <?php print render($page['header_menu']); ?>
    <div id="info">
        <div id="container"></div>
    </div>
</div>
</body>

Code for template.php where menu_tree is overridden:
<?php
function factor_menu_tree__main_menu($variables) {
  return '<ul class="topNav">' . $variables['tree'] . '</ul>';
}

I give only the part where the ul tag should be assigned the topNav class.
factors.info:
name = factor
description =Factor theme
package = Core
version = VERSION
core = 7.x
stylesheets[all][] = style.css
regions[header_menu] = Меню
regions[content] = Content bottom

The theme name is factor, the menu is main_menu. Accordingly, the theme folder is located in sites / all / themes.
Tell me where and what is wrong!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vlad171, 2015-09-12
@Vlad171

The answer was simple: you need to use the machine name of the created menu, but I used just the name. Everything worked out.

A
andead, 2015-09-12
@andead

factor__menu_tree__main_menu -> factor_menu_tree__main_menu

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question