Keyword

Login module and menu items in multilingual site

  • Jaakko Karhu
  • Jaakko Karhu's Avatar Topic Author
  • Offline
  • New Member
More
14 years 3 months ago #77957 by Jaakko Karhu
Hello,I ran in to a small problem with menu items and login module today. If your menu module is set to be seen only when viewing specific menu items, menu disappears when you click 'My page', 'My account' etc. links on login module. This might seem as a minor problem, but with multilingual site it is big issue in a view of user usability. Anyhow, I created a small 'hack' to fix this.To clarify this more, my menu structure is somewhat this:Language menu (Main Menu)||__Finnish|        |__ Home|        |__ Blog|        |__ Contact||__English         |__ Home         |__ ContactSo there's different content in different languages and that's why I ended up in using this structure and M17 language component instead of Joom!Fish. And of course, I have to pick the manually which menus are shown in which menu item.So let's move on. As I stated, when using login module, menu disappear. That's because a href losts item id when being constructed. Follow these steps to make K2 login module to keep track:1. Do a override for K2 login module. Copy files userblock.php and login.php from folder modules/mod_k2_login/tmpl to templates/(your template)/html/mod_k2_login.2. Open userblock and add following lines before unordered list:<?php     $menus = &JSite::getMenu();            $menu  = $menus->getActive();            $itemid = $menu->id; ?>Lines above are totally copy pasted from discussion, which can be found here.3. Edit <a> elements by adding . '&Itemid=' . $itemid in the end of 'a href' formed in code by php. Lines should look like this: <a href="<?php echo JRoute::_('index.php?option=com_user&view=user&task=edit') . '&Itemid=' . $itemid; ?>"><?php echo JText::_('My account'); ?></a>4. Open login.php and do the same trick for that also.I don't know if this is a proper way to achieve the result, but it works for me. Pros, guide me if I'm wrong.Cheers,Jaakko KarhuFinland

Please Log in or Create an account to join the conversation.

  • Jaakko Karhu
  • Jaakko Karhu's Avatar Topic Author
  • Offline
  • New Member
More
14 years 3 months ago #77958 by Jaakko Karhu
Replied by Jaakko Karhu on topic Login module and menu items in multilingual site
Take a note of this also:

If you have selected different language than site default, you might notice that when pressing login/logout, language is reseted back to site default. This problem is also easily solved: set "How long to remember" in M17 module parameters something else than session lifetime (Custom lapse or Permanent).

No clue why this helps, but it does.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum