Refactor submenu system to work everywhere

This change ensures that submenus work correctly in article pages,
profile pages, and in the main header.
Merge pull request #2095 from openjck/fix-submenus

Refactor submenu system to work everywhere