Adding non-menu things to primary links menu items with Drupal 7's page alter hook
The request was to stick search in a menu. I said "I bet that's easy with hook_page_alter()!"
Not quite.
The primary links menu is output directly by the theme, and so is one of the very very few things that occurs after hook_page_alter().
You can tell the theme to stop outputting it directly, and put it in a block that is displayed in a region, or you can add it to the page rendering array in code with hook_page_build().
When exposed this way, as in the usual block system, menu links do in fact show up as wonderful, discrete, modifiable elements that you can stick your own elements of your own into- or drag in the search form to have it rendered there, if you really insist.
Also, when using Devel's kpr() to print something (including when checking off show page alter), Command+F search in your browser does not see text in collapsed elements. At least in Firefox 6. Not sure why, but be warned.
Comments
Post new comment