Zencart添加语言切换按钮


有些客户不喜欢系统自带的下拉框样式,于是自己用JS写一个。
在页首的php文件中(譬如/includes/templates/marcus/common/tpl_header_v1.php)增加对应的JS功能,然后再增加两个对应的图片按钮,示范如下:

function chgLan(obj){
    var cUrl = window.location.href;
    if (cUrl.includes("?language=en") || cUrl.includes("?language=cn")) {
          cUrl = window.location.pathname + window.location.hash;
        }
    if(obj==1){
        cUrl += "?language=en";
    }else if(obj==2){
        cUrl += "?language=cn";
    }
    window.location.href = cUrl;
}
<a href="javascript:chgLan(1)"><img src="/includes/languages/english/images/icon.gif">&nbsp;EN</a>
<a href="javascript:chgLan(2)"><img src="/includes/languages/schinese/images/icon.gif">&nbsp;中文</a>

应用实例:https://www.seerichem.com/

声明:Windows 10 专业版|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - Zencart添加语言切换按钮


Carpe Diem and Do what I like