Hi all,
I am using Zen Cart 1.5.5b, and want to custom to add some php if else code for my skin that with screen width on mobile like iPhone etc display different PHP coding with Google Translate (Two of it)
Yes, I know CSS@media with screen width can help for it, and I am try and add the <div> css class too like this
PHP Code:
@media (max-width: 300px){div.google_translate_element{display: none !important;}}
@media (max-width: 300px){div.google_translate_element-mobile{display: inline-block !important;}}
@media (max-width: 767px){div.google_translate_element{display: inline-block !important;}}
@media (max-width: 767px){div.google_translate_element-mobile{display: none !important;}}
But the BIG problems there for me is ....
If point two Google Translate Code together, only the 8 language work, ALL language one never show (This case will show like two Google Translate, mean without PHP if else, the CSS never work as what I want to be, show one of them coding only and hide other)
Like this one
http://www.myezlap.com/store
or
http://www.myezlap.com/jimmy2.php
Why I am ask for this is because
I go to
http://translate.google.com/translate_tools
And gen two of Google Translate Coding, one for ALL language, and the second one is just few language, total 8 language there (For iPhone width=320px etc)
This is for Desktop Width
PHP Code:
<!-- BoF Google Translate A for Desktop All Language -->
<div class="google_translate_element">
<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, gaTrack: true, gaId: 'UA-89152281-1'}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> </div>
<!-- EoF Google Translate A for Desktop All Language -->
This is for Mobile Width 320px etc (It only show of 8 language)
PHP Code:
<!-- BoF Google Translate C for Mobile Only Hide All Code On Desktop -->
<div class="google_translate_element-mobile">
<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'de,en,es,fr,ja,ko,zh-CN,zh-TW', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false, multilanguagePage: true, gaTrack: true, gaId: 'UA-89152281-1'}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div>
<!-- EoF Google Translate C for Mobile Only -->
Then I try to integration this together, but not work, since I don't know how to write the PHP part if else part
What I try is this now
on
/includes/templates/mytemplate/common/tpl_header.php
PHP Code:
<?php
print <<<_HTML_
<!-- BoF Google Translate A for Desktop All Language -->
<div class="google_translate_element>
<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, gaTrack: true, gaId: 'UA-89152281-1'}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div>
<!-- EoF Google Translate A for Desktop All Language -->
_HTML_;
print <<<_HTML2_
<!-- BoF Google Translate C for Mobile Only Hide All Code On Desktop -->
<div class="google_translate_element-mobile>
<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'de,en,es,fr,ja,ko,zh-CN,zh-TW', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false, multilanguagePage: true, gaTrack: true, gaId: 'UA-89152281-1'}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div>
<!-- EoF Google Translate C for Mobile Only Hide All Code On Desktop -->
_HTML2_;
?>
So I need the coding somthing like this adding the if else that make it work
PHP Code:
<?php
if (screen width=700px) {
print <<<_HTML_
<!-- BoF Google Translate A for Desktop All Language -->
<div class="google_translate_element>
<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, gaTrack: true, gaId: 'UA-89152281-1'}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div>
<!-- EoF Google Translate A for Desktop All Language -->
_HTML_;
} else {
// for Mobile
print <<<_HTML2_
<!-- BoF Google Translate C for Mobile Only Hide All Code On Desktop -->
<div class="google_translate_element-mobile>
<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'de,en,es,fr,ja,ko,zh-CN,zh-TW', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false, multilanguagePage: true, gaTrack: true, gaId: 'UA-89152281-1'}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div>
<!-- EoF Google Translate C for Mobile Only Hide All Code On Desktop -->
_HTML2_;
}
?>
Plese help, and I think this also very useful for anyone the using Responsive Template who also need it
Thank you.
Bookmarks