Thêm “Like to Unlock” vào bài viết Blogspot - 1 trong nhứng thủ thuật blogspot - là 1 cách bắt người dùng phải thích bài hay chia sẻ bài viết  lên 1 mạng xã hội nào đó ví dụ facebook, g+ để thấy được nội dung mà tác giả đã ẩn khi viết bài.  Nó là  phương pháp để tránh " ninja " vào website của bạn " xem chùa " mà không để lại 1 lời bình hay 1 like để ủng hộ tác giả :)




Thêm button “Like to Unlock” vào bài viết Blogspot

#Note: Điều quan trọng trước khi làm là bạn phải sao lưu template blogspot đang sử dụng tránh trường hợp xấu xảy ra.

Xem thêm:



Bước 1: Dán đoạn code sau trước thẻ </head> của template

<script src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'/>
Bước 2: Dán đoạn code sau trước thẻ </body>

<script type='text/javascript'>
  //<![CDATA[
  /* Facebook */
  (function(d, s, id){
       var js, fjs = d.getElementsByTagName(s)[0];
       if (d.getElementById(id)) {return;}
       js = d.createElement(s); js.id = id;
       js.src = "//connect.facebook.net/en_US/all.js";
       fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));
  window.fbAsyncInit = function() {
      // init the FB JS SDK
      FB.init({
        status     : true,                             
        xfbml      : true                               
      });
      FB.Event.subscribe('edge.create', function(href, widget) {
          $.event.trigger({
              type: "pageShared",
              url: href
          }); 
      });
  };
  /* Twitter */
    window.twttr = (function (d,s,id) {
    var t, js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return; js=d.createElement(s); js.id=id;
    js.src="https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs);
    return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } });
  }(document, "script", "twitter-wjs"));
  twttr.ready(function (twttr) {
      twttr.events.bind('tweet', function (event) {
          $.event.trigger({
              type: "pageShared",
              url: event.target.baseURI
          });
      });
  });
  /* Google Plus */
  (function() {
      var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
      po.src = 'https://apis.google.com/js/plusone.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
    })();
  function plusOned(obj){
      console.log(obj);
      $.event.trigger({
          type: "pageShared",
          url: obj.href
      });
  }
  /* Listen for the pageShared event */
  $(document).on('pageShared',function(e){
      if(e.url == window.location.href){
          $(".hide").show();
          $(".show").hide();
      }
  });
  //]]>
</script>
Bước 3: Tìm ]]></b:skin> hoặc </style> và chèn code vào  trước 1 trong 2 thẻ đó

}
.show .fb-like {
  margin-top: 0;
  top: -7px;
  position: relative;
}
.show .twitter-share-button {
  margin-right: 25px;
}
Vậy là xong

Hướng dẫn sử dụng

Khi đăng bài bạn chọn sang viết là HTML rồi dán đoạn code

<div class="hide">
Nội dung bài ẩn của bạn viết tại đây
</div>
<div class="show">
To unlock the content, use one of the social buttons below. Thank you for your support and love.
<span class="fb-like" data-layout="button_count" data-send="false" data-show-faces="false" data-width="90" expr:data-href="data:post.url" style="margin-right: 25px;"></span><a class="twitter-share-button" data-count="horizontal" data-related="" data-via="doiguocmoc"
    expr:data-text="data:post.title" expr:data-url="data:post.url" href="http://twitter.com/share">Tweet</a><span class="g-plusone" data-callback="plusOned" data-count="true" data-size="medium" expr:data-href="data:post.url"></span></div>
code sưu tầm từ mocgin.com
Chúc bạn thành công

#Note: Không nên lạm dụng nhé vì nếu lạm dụng sẽ gây phiền toái cho người đọc.
Axact

Axact

Vestibulum bibendum felis sit amet dolor auctor molestie. In dignissim eget nibh id dapibus. Fusce et suscipit orci. Aliquam sit amet urna lorem. Duis eu imperdiet nunc, non imperdiet libero.

Post A Comment:

0 comments: