User login

Why isn't Drupal's one run-time menu item altering hook getting run?

in

05:15 mlncn: sfreudenberg: any guess why hook_translated_menu_link_alter() is called only on admin theme pages, and then only for user menu (indeed, just the 'user' "User Account" menu item?
05:16 sfreudenberg: yes
05:17 sfreudenberg: if (!empty($item['options']['alter'])) {
05:17 sfreudenberg: drupal_alter('translated_menu_link', $item, $map);
05:17 sfreudenberg: }
05:18 sfreudenberg: it's only run for marked menu items
05:18 sfreudenberg: menu.inc line 921ff
05:19 sfreudenberg: ok. it's not a guess; coincidentally I needed that in another project.
05:19 mlncn: lol, nice
05:21 mlncn: i think i'll just use a preprocess function to add in the active path (mark items as in the active state) but if theoretically i actually wanted to use this function how could i mark things in the first place-- mark it in hook_menu_link_alter()? (which is only run on save)
05:24 sfreudenberg: menu_link_alter is the right place
05:24 sfreudenberg: $item['options']['alter'] = TRUE;

Update: The way this was solved worked out slightly differently. See: Faking an active trail for items not in a menu: Drupal 7 active state for main menu based on content type.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.