WebsiteBaker Community Forum
WebsiteBaker Support (2.10.x) => General Help & Support => Topic started by: Nicky on July 25, 2017, 10:27:58 PM
-
Hello Bakers!
Google or Bing Translate website widget ...
If I embed their javascript in my wb template, they load ok ( either of them ).
But I want to add their javascript to specific wb pages but I cannot get those script(s) to load !
Nothing appears, nor any errors.
Here's the Google's javascript ...
<div id="google_translate_el ement"></div><script type="text/javascript">
function googleTranslateElem entInit() {
new google.translate.Tr anslateElement({pageLanguage: 'en', layout: google.translate.Tr anslateElement.Inli neLayout.SIMPLE, autoDisplay: false, multilanguagePage: true}, 'google_translate_el ement');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
After many days trying different things, what do I need to do to fix this please?
WB-Version 2.10.0
Regards,
N
ps. I've got a weather widget javascript on my home page and that works fine in a wb section !? (Y)
-
Use an extra section of the type "Code". This allows you to use php code.
In that section you can use the "echo" command to output the code like this:
(note the escaped single quotes in the javascript call!)
echo '
<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: \'en\', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false, multilanguagePage: true}, \'google_translate_element\');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
';
-
Many thanks Ruud !
You're a genius (Y) :-D