Why isn't Drupal's one run-time menu item altering hook getting run?
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