I have solved this on a completely different way as I was originally thinking. What I did was the following.
Create a file called "menuitem.php"' In this file create the menuitem and submenuitems if exist
Include this file with all the other files that create the layout. So that it is loaded on all pages.
In menuitem.php create a link to a stylesheet or use inline styles so that you can position the menuitem on the right place.
Use media queries so that is works on all devices.