- This topic has 11 replies, 3 voices, and was last updated 4 years, 8 months ago by Tom.
-
AuthorPosts
-
October 15, 2018 at 12:33 pm #701610Marc Nevens
Hello,
In the mobile view I like to have a language switcher near the hamburger icon, and not in de roll out menu.
I installed the WPML plugin with extensions.
How could I do that?October 15, 2018 at 3:53 pm #701744TomLead DeveloperLead DeveloperHi there,
It would be possible to add it inside a hook using our Elements module, but we’d need to know what WPML function to call.
According to this topic, we can use this:
do_action('wpml_add_language_selector');
So, we can try this:
1. Add a new “Hook” element in “Appearance > Elements”.
2. In the hook content, add this:<div class="mobile-bar-items"> <?php do_action('wpml_add_language_selector'); ?> </div>
3. In the hook settings, choose the
inside_navigation
hook, and execute PHP.4. Set the Display Rules to “Entire Site” and publish.
Now we can hide the current menu item on mobile with this CSS:
.main-navigation.toggled .wpml-ls-item { display: none; }
October 16, 2018 at 3:07 am #702023Marc NevensHello,
thank you for your quick reply.
I made the new hook like described in your message, but language switcher is not showing up.
My website url is https://hdm.undeployed.beOctober 16, 2018 at 3:26 pm #702638TomLead DeveloperLead DeveloperAh sorry, you’re using the mobile header.
Use the
inside_mobile_header
hook instead.October 17, 2018 at 2:18 am #702922Marc NevensHi Tom,
I tried to change the hook location to
inside_mobile_header
, but without any result.
I still see the language switcher in the side-out menu, and not near the hamburger menu.Regards,
Marc
October 17, 2018 at 9:23 am #703420TomLead DeveloperLead DeveloperAh, the code is there now. However, it’s hidden because it’s actually a dropdown menu (obviously, as seen on desktop). I’m not sure how this would work on mobile? How would the user choose from different languages?
October 18, 2018 at 1:58 am #703871Marc NevensHi Tom,
the user will tap on the language icon, and will chose is prefered language in the dropdown menu.October 18, 2018 at 10:03 am #704359TomLead DeveloperLead DeveloperCurrently, that would require some decent javascript coding.
I wonder if WPML has something built in where you can call a function that outputs a dropdown? Might be worth asking them.
October 23, 2018 at 12:19 pm #708486Marc NevensHello,
I could put the language switcher in the mobile header, but he will not show up in the mobile view. You could see it. I put the code in a div tag with a red background. Is this a css problem, that the selector won’t shop up?
October 23, 2018 at 6:22 pm #708665TomLead DeveloperLead DeveloperI’m not seeing the code anymore – did you remove it?
It wasn’t displaying because
<ul>
elements are hidden by default in the mobile header. The reason we didn’t display them is that they would have displayed as an unordered list (not a dropdown) and messed up the element.July 28, 2019 at 4:18 pm #969590liorsade8hi
any news on this?
i really need in multi language sites the option to change between language in the mobile header menu
mobile bar…
please update.
thanksJuly 28, 2019 at 7:07 pm #969660TomLead DeveloperLead DeveloperHi there,
I don’t have any updates, but I’ll reach out to WPML to see if there’s something we can do.
-
AuthorPosts
- You must be logged in to reply to this topic.