Select the FCKEditor language - full example
Posted June 28th, 2009 in FCKEditor
I had an email from someone asking about my "Select the interface language in FCKEditor from a select box" post and where they should put the Javascript and drop down box. This post shows the full PHP page required to display the FCKEditor with language selection drop down boxes.
The code does not contain the necessary work to save it to the database; it just shows how to have all the elements in your page.
A working example (using FCKEditor 2.6.2) can be found here.
And here is the code behind that page:
<html>
<head>
<title>FCKEditor Change Language Example</title>
<script language="javascript">
function FCKeditor_OnComplete(editor) {
var select = document.getElementById("languages");
for(lang in editor.Language.AvailableLanguages) {
select.options[select.options.length] =
new Option(editor.Language.AvailableLanguages[lang], lang);
}
select.value = editor.Language.ActiveLanguage.Code;
}
function change_language(lang) {
window.location.href = window.location.pathname + "?lang=" + lang ;
}
</script>
</head>
<body>
<select id="languages" onchange="change_language(this.value);">
</select>
<?php
require_once('fckeditor/fckeditor.php');
$oFCKeditor = new FCKeditor('html');
if(isset($_GET['lang'])) {
$oFCKeditor->Config['AutoDetectLanguage'] = false ;
$oFCKeditor->Config['DefaultLanguage'] = $_GET['lang'] ;
}
else {
$oFCKeditor->Config['AutoDetectLanguage'] = true ;
$oFCKeditor->Config['DefaultLanguage'] = 'en' ;
}
$oFCKeditor->Create();
?>
</body>
</html>
Related posts:
- Select the interface language in FCKEditor from a select box (Friday, March 6th 2009)
- Add options to an HTML select box with Javascript (Tuesday, March 3rd 2009)
- Language selection with FCKEditor (Sunday, February 22nd 2009)
- Always make FCKEditor paste as plain text (Tuesday, November 11th 2008)
- Using the FCKEditor HTML Editor with PHP (Wednesday, August 20th 2008)

Comments
blog comments powered by Disqus