Đăng Nhập

Vui lòng khai báo chính xác tên truy cập và mật khẩu!

Quên mật khẩu?

    Hot...! Tooltip Zoom hình cho Nukeviet.

      Thành Viên Chính Thức
      nhatky2112

      Giới tính : Nam

      Tuổi : 33

      Đến từ : tp hcm

      Ngày Tham gia : 21/02/2012

      Tổng số bài gửi : 6

      #1

       Mon Mar 12, 2012 6:07 pm

      tungkiet đã viết:Mời các bác ghé thăm http://em102.tk

      Sau đây là chia sẻ cách làm rất đơn giản của mình:
      Bước 1:
      Sửa file: modules\shops\theme.php
      thêm đoạn này vào dòng 50:
      Code:
      $xtpl->assign( 'intro', $data_row_i['hometext'] );

      Bước 2:
      Sửa file: modules\shops\funcs\main.php
      Sửa đoạn:
      Code:
      $sql = "SELECT id,listcatid, publtime, " . NV_LANG_DATA . "_title," . NV_LANG_DATA . "_alias, " . NV_LANG_DATA . "_hometext, " . NV_LANG_DATA . "_address, homeimgalt, homeimgthumb, product_price,product_discounts, money_unit,showprice  FROM `" . $db_config['prefix'] . "_" . $module_data . "_rows` WHERE inhome=1 AND status=1 AND publtime < " . NV_CURRENTTIME . " AND (exptime=0 OR exptime>" . NV_CURRENTTIME . ") ORDER BY ID DESC LIMIT 0," . $num . "";
      Thành:
      Code:
      $sql = "SELECT id,listcatid, publtime, " . NV_LANG_DATA . "_title," . NV_LANG_DATA . "_alias, " . NV_LANG_DATA . "_hometext, " . NV_LANG_DATA . "_address, homeimgfile,homeimgalt, homeimgthumb, product_price,product_discounts, money_unit,showprice  FROM `" . $db_config['prefix'] . "_" . $module_data . "_rows` WHERE inhome=1 AND status=1 AND publtime < " . NV_CURRENTTIME . " AND (exptime=0 OR exptime>" . NV_CURRENTTIME . ") ORDER BY ID DESC LIMIT 0," . $num . "";

      Sửa đoạn:
      Code:
       $s = "SELECT SQL_CALC_FOUND_ROWS id, publtime, " . NV_LANG_DATA . "_title," . NV_LANG_DATA . "_alias, " . NV_LANG_DATA . "_hometext, " . NV_LANG_DATA . "_address, homeimgalt, homeimgthumb, product_price,product_discounts, money_unit,showprice  FROM `" . $db_config['prefix'] . "_" . $module_data . "_rows` WHERE listcatid IN (" . implode( ",", $array_cat ) . ") AND inhome=1 AND status=1 AND publtime < " . NV_CURRENTTIME . " AND (exptime=0 OR exptime>" . NV_CURRENTTIME . ") ORDER BY ID DESC LIMIT 0," . $array_info_i['numlinks'] . "";
      Thành:
      Code:
      $s = "SELECT SQL_CALC_FOUND_ROWS id, publtime, " . NV_LANG_DATA . "_title," . NV_LANG_DATA . "_alias, " . NV_LANG_DATA . "_hometext, " . NV_LANG_DATA . "_address, homeimgalt, homeimgfile,homeimgthumb, product_price,product_discounts, money_unit,showprice  FROM `" . $db_config['prefix'] . "_" . $module_data . "_rows` WHERE listcatid IN (" . implode( ",", $array_cat ) . ") AND inhome=1 AND status=1 AND publtime < " . NV_CURRENTTIME . " AND (exptime=0 OR exptime>" . NV_CURRENTTIME . ") ORDER BY ID DESC LIMIT 0," . $array_info_i['numlinks'] . "";

      Sửa đoạn:
      Code:
      $data_pro[] = array(
                          "id" => $id, "publtime" => $publtime, "title" => $title, "alias" => $alias, "hometext" => $hometext, "address" => $address, "homeimgalt" => $homeimgalt, "homeimgthumb" => $thumb[0], "product_price" => $product_price, "product_discounts" => $product_discounts, "money_unit" => $money_unit,"showprice" => $showprice, "link_pro" => $link . $global_array_cat[$catid_i]['alias'] . "/" . $alias . "-" . $id, "link_order" => $link . "setcart&id=" . $id
                      );
      Thành:
      Code:
      $data_pro[] = array(
                          "id" => $id, "publtime" => $publtime, "title" => $title, "alias" => $alias, "hometext" => $hometext, "address" => $address, "homeimgalt" => $homeimgalt,"homeimgfile" => $homeimgfile,  "homeimgthumb" => $thumb[0], "product_price" => $product_price, "product_discounts" => $product_discounts, "money_unit" => $money_unit,"showprice" => $showprice, "link_pro" => $link . $global_array_cat[$catid_i]['alias'] . "/" . $alias . "-" . $id, "link_order" => $link . "setcart&id=" . $id
                      );

      Sửa đoạn:
      Code:
      while ( list( $id, $listcatid, $publtime, $title, $alias, $hometext, $address, $homeimgalt, $homeimgthumb, $product_price, $product_discounts, $money_unit ,$showprice) = $db->sql_fetchrow( $result ) )
          {
      Thành
      Code:
      while ( list( $id, $listcatid, $publtime, $title, $alias, $hometext, $address, $homeimgfile, $homeimgalt, $homeimgthumb, $product_price, $product_discounts, $money_unit ,$showprice) = $db->sql_fetchrow( $result ) )
          {

      Sửa đoạn:
      Code:
      while ( list( $id, $publtime, $title, $alias, $hometext, $address, $homeimgalt, $homeimgthumb, $product_price, $product_discounts, $money_unit,$showprice ) = $db->sql_fetchrow( $re ) )
                  {
      Thành:
      Code:
      while ( list( $id, $publtime, $title, $alias, $hometext, $address, $homeimgalt,$homeimgfile,  $homeimgthumb, $product_price, $product_discounts, $money_unit,$showprice ) = $db->sql_fetchrow( $re ) )
                  {

      Bước 3:
      Sửa file: themes\default\modules\shops\main_procate.tpl (Các này chỉ là ví dụ 1 file.. còn bạn thích tooltip file nào thì làm tương tự)
      Thên đoạn sau dưới dòng
      Code:
      <script type="text/javascript">
      $(document).ready(function() {
        //Tooltips
          var tip = null;

          $(".tip_trigger").hover(function(){

              //Caching the tooltip and removing it from container; then appending it to the body
              tip = $(this).find('.tip').remove();
              $('body').append(tip);

              tip.show(); //Show tooltip


          }, function() {

              tip.hide().remove(); //Hide and remove tooltip appended to the body
              $(this).append(tip); //Return the tooltip to its original position

          }).mousemove(function(e) {
          http://console.log(e.pageX)
                if ( tip == null ) return;


                var mousex = e.pageX + 20; //Get X coodrinates
                var mousey = e.pageY + 20; //Get Y coordinates
                var tipWidth = tip.width(); //Find width of tooltip
                var tipHeight = tip.height(); //Find height of tooltip

              //Distance of element from the right edge of viewport
                var tipVisX = $(window).width() - (mousex + tipWidth);
                var tipVisY = $(window).height() - (mousey + tipHeight);

              if ( tipVisX < 20 ) { //If tooltip exceeds the X coordinate of viewport
                  mousex = e.pageX - tipWidth - 20;
                  $(this).find('.tip').css({  top: mousey, left: mousex });
              } if ( tipVisY < 20 ) { //If tooltip exceeds the Y coordinate of viewport
                  mousey = e.pageY - tipHeight - 20;
                  tip.css({  top: mousey, left: mousex });
              } else {
                  tip.css({  top: mousey, left: mousex });
              }
          });

      });

      </script>
      Sửa đoạn sau:
      Code:
      <div class="content_top">
        <a href="{LINK}" title="{TITLE}">
            <img src="{IMG_SRC}" alt="" style="max-height:{height}px;max-width:{width}px;"/>
          </a><br />
        <span><a href="{LINK}" title="{TITLE}">{TITLE0}</a></span><br />
      </div>
      Thành
      Code:

      <div class="content_top">
      <a class="imgsidder tip_trigger" href="{LINK}" title="{TITLE}">
                                     <img src="{IMG_SRC}" style="max-height:{height}px;max-width:{width}px;"/>
                                    <span class="tip">
                               {TITLE0}
                               <hr width="100%" style="border-bottom-color:#999999; border-bottom-style:1em;" /><br />
                                 <img src="{IMG_SRC}" width="200px;"/>
                              <br />
                              {intro}
                              </span>
                           </a>
                        <br />
                              <span><a href="{LINK}" title="{TITLE}">{TITLE0}</a></span><br />
      </div>
      <sfdocready id="sfDocReady"></sfdocready>

      Bước cuối:
      Sửa file: themes\default\css\shops.css
      Thêm đoạn sau vào dòng đầu tiên
      Code:
      /*--Tooltip Styles--*/
      .tip {
          color: #fff;
          background:#1d1d1d;
          padding:10px;
          position:absolute;   
          z-index:1000;
          -webkit-border-radius: 3px;
          -moz-border-radius: 3px;
          border-radius: 3px;
         width:210px;
      }

      .tip_trigger .tip { display:none; }
      .tip img{border:#EFEFEF 1px solid;padding:2px}

      Kết quả: Vào admin dọn dẹp cache và test thử xem thế nào

      Mình trích dẫn bên Forum Nukeviet, các bạn có thể qua đó tham khảo thêm nha, làm đúng các bước thành công 100%.

      http://nukeviet.vn/phpbb/posting.php?mode=quote&f=119&p=87618
      Thanks cho mình cái lấy tinh thần nha.hjhj.
      Admin
      Admin

      Giới tính : Nam

      Đến từ : TPHCM

      Ngày Tham gia : 03/04/2011

      Tổng số bài gửi : 2292

      #2

       Mon Mar 12, 2012 7:34 pm

      thank bạn hay đó!