WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.9 is now available!


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.10.x) »
  • General Help & Support »
  • Google or Bing Translate website widget
  • Print
Pages: [1]   Go Down

Author Topic: Google or Bing Translate website widget  (Read 9711 times)

Offline Nicky

  • Posts: 94
  • Gender: Male
Google or Bing Translate website widget
« 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)
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Google or Bing Translate website widget
« Reply #1 on: July 25, 2017, 11:21:48 PM »
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!)

Code: [Select]
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>
';
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

Offline Nicky

  • Posts: 94
  • Gender: Male
Re: Google or Bing Translate website widget
« Reply #2 on: July 26, 2017, 01:50:44 PM »
Many thanks Ruud !

You're a genius  (Y)  :-D
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.10.x) »
  • General Help & Support »
  • Google or Bing Translate website widget
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2