I'm trying to use theme-preprocess-menu(&$variables) to get an additional variable into the menu template in my sub-theme, but it isn't in the commented out list of functions in the sub-theme's generated theme file, and doesn't work when I add it in.

I have also tried theme-preprocess-menu__main(&variables) following the theme hook suggestion in Twig debug, but this too doesn't work.

In all cases, I have flushed the cache.

Have I missed enabling this hook somewhere as it is used in at-core?

Update: It seems that the hook ISworking, but the code I am using to add to $variables is not affecting the array. However, the same code in preprocess_node works?

Is there any reason why this would work in one preprocess hook, but not another?

$variables['my_key'] = 'My value';

Comments

gurrmag created an issue. See original summary.

gurrmag’s picture

Issue summary: View changes
Jeff Burnz’s picture

You'll have to show all your code, cheers.

Jeff Burnz’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)
Jeff Burnz’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

No feedback.