Different Menu for mobile and web

Posted in: Newsmag
Post count: 46

Hi i have Newsmag Theme v2.2

i want to know is there any way that i could get different menu for WEB and different menu for Mobile .??
if yes how can i achieve this.

Post count: 6535

Hi

There is no easy way to achieve that. The coding method is a bit complicated as it will involve hard-coding the option. You can follow this topic to see how registering a new menu can be done: https://forum.tagdiv.com/topic/conditional-logic-for-menu/ This is for having different menus for different users but the principles are the same. However it will not be so easy to adapt it to your preference so I suggest you hire someone to help out in this case.

Thanks!

Post count: 10

Hi,

I managed to create and insert a new menu for the mobile view.
It shows up in the admin panel and loads the elements in the front-end perfectly, but somehow it’s breaking the code of the submenus (both standard and mega menus) that I have in the main menu.

Let’s see if I can make it more clear:
If I open ‘menu-mobile.php’ and switch back to using ‘header-menu’ everything gets back to normal (submenus in the desktop view appear as they should) but when using my new ‘mobile-menu’ they just show a list of subcategories, unstyled and without images.

I tried using other menus in my ‘menu-mobile.php’, or even deleting all the code related to loading one, but the same keeps happening. It somehow seems to need ‘header-menu’ to be loaded in there.

Do you have any clue of how to solve this issue?

[Note]
Just to see if the problem was coming from my new menu I tried to use both at the same time.
In this scenario everything works as it should, but well, It’s not ideal to have both menus in the mobile view, isn’t it? 🙂

Post count: 6535

Hi

You don’t have to edit the menu-mobile.php. The point if to register a new menu in td-menu.php then load this menu only when a mobile devices is detected. For this you will need a custom javascript which detect the screen width and loads the menu conditional. You can take a look at the examples from this topic, it may help you to develop the required code:http://stackoverflow.com/questions/1504459/getting-the-screen-resolution-using-php
Also follow the exact instructions from the above topic to register the new menu but you have to adapt it in order to be loaded only for mobile devices.

Thanks!

Post count: 10

Thanks for your answer Andrei, and for taking the time to find the link to the JS code.

I was trying to get a solution that works purely from the child-theme, hence my attempt to solve it from menu-mobile.php, but will give a go to yours 😉

Post count: 6535

Hi

Note that not any file can be modified in child theme. For more details about the child theme support with our theme please check this link: https://forum.tagdiv.com/newsmag-child-theme-support/

Thanks!

Viewing 6 posts - 1 through 6 (of 6 total)
The forum ‘Newsmag’ is closed to new topics and replies.