Thứ Tư, 1 tháng 11, 2017

Tạo Thống kê Blogspot tuyệt đẹp cho blog

Chào các bạn, hôm nay mình sẽ hướng dẫn cho các bạn thêm widget thống kê blog tuyệt đẹp

HƯỚNG DẪN CÁCH LÀM:

Bước 1 : Đăng nhập vào blog --> Bố cục --> Thêm tiện ích --> Thống kê blog và chọn kiểu 2 --> Lưu


Bước 2 : Vào chủ đề và tìm đoạn id='Stats1' và bôi đen toàn bộ <b:widget id='Stats1' locked='false' title='Tổng số lượt xem trang' type='Stats'>...</b:widget>
và thay nó thành đoạn code phía dưới
<b:widget id='Stats1' locked='false' title='' type='Stats' version='1'>
            <b:widget-settings>
              <b:widget-setting name='showGraphicalCounter'>false</b:widget-setting>
              <b:widget-setting name='showAnimatedCounter'>false</b:widget-setting>
              <b:widget-setting name='showSparkline'>false</b:widget-setting>
              <b:widget-setting name='sparklineStyle'>BLACK_TRANSPARENT</b:widget-setting>
              <b:widget-setting name='timeRange'>ALL_TIME</b:widget-setting>
            </b:widget-settings>
            <b:includable id='main'>
  <b:if cond='data:title != &quot;&quot;'><h2><data:title/></h2></b:if>
  <div class='widget-content'>
            <!-- Add the bg color to the header using any of the bg-* classes -->
            <div class='aubout-admin'>
              <div class='admin-image'>
                <img alt='User Avatar' class='img-circle' src='https://i.imgur.com/HmyKG6e.jpg'/>
              </div>
              <!-- /.widget-user-image -->
              <h3 class='admin-username'>Trần Thanh Bình</h3>
              <h5 class='admin-desc'>Designer and Developer</h5>
            </div>
    <!-- Content is going to be visible when data will be fetched from server. -->
    <div expr:id='data:widget.instanceId + &quot;_content&quot;' style='display: none;'>
      <!-- Counter and image will be injected later via AJAX call. -->
      <b:if cond='data:showSparkline'>
        <img alt='Sparkline' expr:id='data:widget.instanceId + &quot;_sparkline&quot;' height='30' width='75'/>
      </b:if>
      <span expr:class='&quot;counter-wrapper &quot; + (data:showGraphicalCounter ? &quot;graph-counter-wrapper&quot; : &quot;text-counter-wrapper&quot;)'><a expr:id='data:widget.instanceId + &quot;_totalCount&quot;'/></span>
      <b:include name='quickedit'/>
    </div>
  </div>
<script type='text/javascript'>
   function postCount(json){
    document.write(&quot;<span class='counts post2'> Tổng bài viết &quot;);
    var count = json.feed.openSearch$totalResults.$t;
    document.write(&quot;<span class='count all-posts'>&quot; + count + &quot;</span>&quot;);
    document.write(&quot;</span>&quot;)
  }
  function numberOfComments(json){
    document.write(&quot;<span class='counts comment2'> Tổng nhận xét &quot;);
    var count = json.feed.openSearch$totalResults.$t;
    document.write(&quot;<span class='count all-comments'>&quot; + count + &quot;</span>&quot;);
    document.write(&quot;</span>&quot;)
   }
 </script>
<script src='/feeds/posts/default?alt=json-in-script&amp;max-results=0&amp;callback=postCount' type='text/javascript'/>
<script src='/feeds/comments/default?alt=json-in-script&amp;max-results=0&amp;callback=numberOfComments'/>
</b:includable>
          </b:widget>

Bước 3 : Để làm đẹp cho đoạn code thống kê, bạn tìm đến thẻ ]]></b:skin> và dán đoạn code bên dưới lên trên nó nhé.
/* Thong ke */
.aubout-admin{background-color:#f39c12;color:#fff;padding:20px;border-top-right-radius:3px;border-top-left-radius:3px;height:64px}
.admin-image img{width:65px;height:auto;float:left;border-radius:50%}
.admin-username,admin-desc{margin-left:75px}
.admin-username{margin-top:5px;margin-bottom:5px;font-size:25px;font-weight:300}
.admin-desc{margin-top:0;font-size:14px;font-weight:300}
#Stats1{background:#fff!important;padding: 0px!important}
a#Stats1_totalCount:before{line-height:37px}
a#Stats1_totalCount{background:#dd4b39;color:#fff;padding: 0px 7px 1px 7px;border-radius: 20px;}
.Stats .counter-wrapper{width:98%;text-align:right;margin:6px 25px 12px 0px;font-weight:500;line-height:35px;color:#333;font-size:16px;border-bottom: 1px solid #f4f4f4;padding-bottom:12px}
.Stats .counter-wrapper:after{content:"Tổng lượt xem ";float:left;text-align:left;font-size:16px;color:#333;}
.counts {display:inline-block;width:98%;font-size:16px;line-height:22px;color:#333;border-bottom: 1px solid #f4f4f4;margin-bottom:11px}
.counts .count{display:inline-block;font-size:16px;vertical-align:top;direction:ltr;float:right;color:#fff;width:40px;text-align:center;line-height:22px;border-radius:16px}
.counts:hover .titles:before{color:#333!important;border-radius:2px;border-color:rgba(255,255,255,0.1);}
.post 2{margin-bottom:10px}
.all-posts{background:#00a65a}
.all-comments{background:#00c0ef}
.counter-wrapper.text-counter-wrapper:before,.counts:before{display:inline-block;font-size:16px;font-family:FontAwesome;font-style:normal;margin:0 10px 0 10px;float:left;width:10px;text-align:center;}
.counts:before{display:block;color:#333;width:35px;height:35px;font-size:16px;line-height:24px;border-radius:2px;margin:0px 8px 0 0;}
.counter-wrapper.text-counter-wrapper:before{content:"\f080";margin:0px 25px 0px 9px!important}
.counts.post2:before {content:"\f044";}
.counts.comment2:before {content:"\f0e6"}
#Stats1_content {width:auto;height:auto}
.comment2{margin-bottom:0!important}
* Nếu có CSS trước đó thì nhớ xóa css có từ trước đó để tránh lỗi.
Chúc bạn thành công!