• 给网站添加google翻译工具

    这里添加的翻译工具是翻译整个网站的,至于在网站中添加一个翻译模块 网上很多童鞋已经贴出了相应的方法,这边我就不介绍了

    方法将以下代码添加到对应文件中即可,比如Magento模板中我们可以把它添加到header.phtml中

    <div id=”google_translate_element”></div><script>
    function googleTranslateElementInit() {
    new google.translate.TranslateElement({
    pageLanguage: ‘en’,
    multilanguagePage: true,
    layout: google.translate.TranslateElement.InlineLayout.SIMPLE
    }, ‘google_translate_element’);
    }
    </script><script src=”//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit”></script>

     

    代码来源:

    http://translate.google.com/translate_tools

    大家可以根据自己的不同需求进行设置。

    记此以作备忘 :-)

  • 网页或邮件中添加新浪微博

    使用博客挂件

    http://weibo.com/plugins/widget.php

    登录之后 进入工具  使用博客挂机,微博秀,以及签名档均可实现  添加展示微博的功能

    这边我使用的是签名档,当然还可以选择不同的样式咯 更改 图片 路径后的数字  分别对应效果如下:

     
    vsfor weibo style 1 vsfor weibo style 1 vsfor weibo style 2 vsfor weibo style 3 vsfor weibo style 4 vsfor weibo style 5 vsfor weibo style 6 vsfor weibo style 7 vsfor weibo style 8 vsfor weibo style 9 
     
    登录 微博 设置你喜欢的样式吧
  • css3 实现div圆角和阴影

    rounded corners and shadow  for   Firefox, Safari/Chrome, Opera and IE9.

    使用css 3 实现 div 层的圆角和阴影

    Here’s a few basic examples that should work in current versions of Firefox, Safari/Chrome, Opera and even IE9:

    #Example_A
    -moz-border-radius-bottomright: 50px;
    border-bottom-right-radius: 50px;
    
    #Example_B
    -moz-border-radius-bottomright: 50px 25px;
    border-bottom-right-radius: 50px 25px;
    
    #Example_C
    -moz-border-radius-bottomright: 25px 50px;
    border-bottom-right-radius: 25px 50px;
    
    #Example_D
    -moz-border-radius: 1em 4em 1em 4em;
    border-radius: 1em 4em 1em 4em;
    
    #Example_E
    -moz-border-radius: 25px 10px / 10px 25px;
    border-radius: 25px 10px / 10px 25px;
    
    #Example_F
    -moz-border-radius: 35px;
    border-radius: 35px;

    The box-shadow property can accept a comma-serparated list of shadows

    参考网站:css3.info

     

  • 获取对象所包含的类方法及相关数据

    在Magento开发模板的时候,我们经常需要从产品或其他对象中取得一些可用方法

    当然基本的 print_r(get_class_method(get_class($temp_object)));  已经基本够用了,但是输出的格式 等等还是看起来有点让人头疼,这边稍微格式化了一下。

    多的不说了直接上代码:

    function objInfo($temp_obj){ //show object class methods data information
    $temp_class = get_class($temp_obj);
    if(!$temp_class) {
    echo “\$$temp_obj  is not an object ~!<br>”;
    print_r($temp_obj);
    echo “<hr>”;
    return 0;
    }
    $details = ”;
    $temp_methods = get_class_methods($temp_class);
    $details .= (‘The Object of Class: ‘.$temp_class.’ –totaly has ‘.count($temp_methods).’ Methods<hr>’);
    $temp_vars = get_class_vars($temp_class);
    foreach($temp_methods as $temp_method){
    $details .= (“\$object->”.$temp_method.”()<br>”);
    }
    $details .= ‘<hr>’;
    if(in_array(‘debug’,$temp_methods)) {
    $details .= ‘<h2>debug() method returns</h2><hr>’;
    $temp_data = $temp_obj->debug();
    foreach($temp_data as $_var => $_value){
    if(!is_array($_value))  $details .= ($_var.’ === ‘.$_value.”<hr>”);
    else {
    $details .= $_var .” === array (“;
    foreach($_value as $t_var => $t_value)
    $details .=  (‘ ['.$t_var.' = '.$t_value.'] ‘);
    $details .= ‘)’;
    }
    }
    }
    if(in_array(‘getData’,$temp_methods)) {
    $details .= ‘<h2>getData() method returns</h2><hr>’;
    $temp_data = $temp_obj->getData();
    foreach($temp_data as $_var => $_value){
    $details .= ($_var.’ === ‘.$_value.”<hr>”);
    }
    }
    print_r($details);
    return 1;
    }//objInfo end;
    objInfo($_product); //输出$_product 的相关信息

    开始是考虑用反射API来取得一些更详细的信息,发现有点太画蛇添足了。。。

    就简单点做个备忘吧…

  • PHP页面跳转后传值编码问题

    网站分页或进行属性筛选时,如果没有使用Ajax动态刷新模块,而是采用post或get的模式传参,经常会碰到中文属性乱码的问题。 至于urlencode  urldecode 在传值前及值接收时的操作,就不用说了

    中文网站,是用浏览器访问时,站点代码采用utf8进行编码, 跳转所传的中文却被转换成了GBK的编码,这个时候就需要进行一些特别处理了,就是转码。

    当然转码之前首先要判断一下字符串是否已经是utf8的编码了,功能函数如下

    // Returns true if $string is valid UTF-8 and false otherwise.
    function is_utf8($word)
    {
    if (preg_match("/^([".chr(228)."-".chr(233)."]{1}[".chr(128)."-".chr(191)."]{1}[".chr(128)."-".chr(191)."]{1}){1}/",$word) == true || preg_match("/([".chr(228)."-".chr(233)."]{1}[".chr(128)."-".chr(191)."]{1}[".chr(128)."-".chr(191)."]{1}){1}$/",$word) == true || preg_match("/([".chr(228)."-".chr(233)."]{1}[".chr(128)."-".chr(191)."]{1}[".chr(128)."-".chr(191)."]{1}){2,}/",$word) == true)
    {
    return true;
    }
    else
    {
    return false;
    }
    } // function is_utf8

    如果不是,就使用 iconvmb_convert_encodingutf8_encode  对此参数进行转码,至于这几个转码函数   php手册中有详细介绍,这边就不赘述了,不同的服务器环境 可能需要不同的函数,不然可能还会出问题

    好了就记到这边  :-)

click
©2010-2024 Jeen All Rights Reserved.Powered by emlog 京ICP备15058100号-1