Hello, I'd like to use a simple menu to switch between two possible languages for content. I've got the content separated out following the markmin get_content() model so want to use a global variable `lang` to direct the path of the content to be loaded in pages. I've got a couple of URLs defined showing flags for the two languages and an if statement that switches which is 'active'.
{{en_URL = IMG(_src=URL('static','images/gb.svg'), _height='12px')}} {{my_URL = IMG(_src=URL('static','images/my.svg'), _height='12px')}} {{if lang == 'en': active_lang_html = en_URL inactive_lang_html = my_URL elif lang == 'my': inactive_lang_html = en_URL active_lang_html = my_URL }} {{pass}} These are then shown to the user by a small menu defined in layout.html: {{=MENU([(active_lang_html, True, None, [ (inactive_lang_html, True, None, []) ])], _class='nav navbar-nav',li_class='dropdown', ul_class='dropdown-menu')}} So the active language is shown as the menu header, with the inactive language shown as a dropdown submenu item. What I'd like to be able to do is to have choosing the submenu change the value of `lang` so that this code can then swap the top menu items and allow the content to be toggled. I can see that each menu item could have a controller that changes the variable `lang`, but I don't then want to load a new view, just alter the view of the current page with the new value of the global variable. Any suggestions? Cheers, David -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.