HTML code for switching between two languages from current page
I'd like to create an HTML block in the frontpage for direct switching between two languages from any current page on the frontpage course. I've found some interesting similar ideas, but what I want to do is a little different: how to get the current filepath, filename and itemid (eg. http://mysite.com/moodle/mod/resource/view.php?id=6936) by HTML code, so I can add the suffix '&lang=xx' for direct switching language on this current page.
The expected result is that when the user change to another page, he/she can always see the HTML block, where the language switching suffix does not change but only the filepath, filename and itemid. With this function, the user does not need to return to the index page everytime he/she want to change the prefered language.
May you help me to learn about this?
Re: HTML code for switching between two languages from current page
Anyway, in Moodle 1.9, you can get the URL of the current page by using the fullme() function or the $FULLME global, and then add &lang=xx to that. (In Moodle 2.0, use $PAGE->url instead of $FULLME.)
Re: HTML code for switching between two languages from current page
Re: HTML code for switching between two languages from current page
Good morning,
I've just posted my problem today and now I see this very very interesting solution, that could resolve half of my problem !
Tim please, could you give me the complete code for Moodle 1.9 to get the url of the current page (because it's not very clear for me ) ? I have this code on the mainmenu-top.php file of my theme (include in my header file) :
<?php
echo '<div id="mainmenu-langopt">';
if (empty($CFG->langmenu)) {
$langmenu = '';
} else {
$currlang = current_language();
$langs = get_list_of_languages();
$langlabel = get_accesshide(get_string('language'));
$langmenu = popup_form($CFG->wwwroot .'/index.php?lang=', $langs, 'chooselang', $currlang, '', '', '', true, 'self', $langlabel);
}
echo $langmenu;
echo '</div>';
?>
What may I modify exactly ?
Many thanks.
Best regards.
Re: HTML code for switching between two languages from current page
Hi Lisa I came across your post in moodle regarding the switch between 2 languages. Did you complete this task? May I trouble you to ask how you did this? I am working in the latest version of moodle 2.4
Many thanks
Sarah x
Re: HTML code for switching between two languages from current page
Guys,
If anyone can help me with this I would be grateful. I wish to be able to use the two languages German and English if someone can guide me on how to do this. I have read all the forums I can find but many of these are so old I am not sure there solution would be helpful for the latest moodle version 2.4
Thanking you in advanced. Sarah x
Re: HTML code for switching between two languages from current page
All done by working through https://tracker.moodle.org/browse/MDL-32257