Langsung ke konten utama

Blogger: Disqus Comment on Click with API Counter Comment Count

Jangan lupa membaca artikel tentang bisnis di > Informasi bisnis terbaik 2020.

We will about to implementing disqus Comment on Click event with Comment post Count using API Call. This one has advantage eg: does not have delay on showing our post comment count like count.js do, but in basic free disqus plan have disadvantage 1000x callback (1k uses / api call) per hour. If you are looking method without an API (without limit), see post Load Disqus On Click Without API.

Before we we begin, we must already have disqus public API KEY. to get one, go to disqus site and login, see the bottom part of that page and click on API links. For detail, see post How To Get Disqus Public API Key.


Still on disqus site, go to disqus admin site setting page and click on "Community". On the right side we have three "Comment Count Link". by default it filled with : Zero comment : 0 Comments, One comment : 1 Comments, Multiple : {num} Comments. We have to Change that comment counter text on that field with removing all " Comments" text, so it will look like : 0, 1, and {num}. Click on Save button to make changes.


DEMO

Show / Write Comments
Now go to your blogger site admin page. If you have already installed disqus widget, remove it first from the left sidebar "Layout" page. Next, click on "Theme" on the left sidebar. On the new right interface you will notice "Backup /Restore" button, hit that to download and save your xml theme script, in case we got messing around it can be restored with that xml by hitting the button again.

On the "Theme" Section, Click on "Edit HTML", click on our html text area box then hit CTRL + F on the keyboard, then fill with <b:includable id='comments' var='post'> on the input text area new ones appear in our html code box, then hit Enter on the keyboard.

Once the result found, we are shown the highlighted keyword. if it still wrapped, click on ">" on the left line of the highlighted word to expand, so we got code structure shown like below :

<b:includable id='comments' var='post'>  <div class='comments' id='comments'>   <a name='comments'/>   <b:if cond='data:post.allowComments'>    <h4><data:post.commentLabelFull/>:</h4> 

We are about to modify on that structure, to make it look like this :

<b:includable id='comments' var='post'>  <div class='comments' id='comments'>   <!-- Paste our newly disqus block code below here -->   <a name='comments'/>   <b:if cond='data:post.allowComments'>    <h4><data:post.commentLabelFull/>:</h4>  

Copy this block code and paste below <div class='comments' id='comments'> , then you must make change on script part at var disqus_shortname = 'Your_Disqus_API_Public_Key' and var disqus_shortname = 'Your_Disqus_Shortname' with your given Api Key and Shortname, save.

<!-- Disqus Block Code --> <b:if cond='data:view.isPost'> <style> #disqus-box {     background-color: #2e9fff;     color: #fff;     font-size: 16px;     font-weight: 600;     height:100px;     text-align: center;     width: 100%;     border-width: 0px;     margin: 20px 0px;     cursor: pointer;     border-radius: 5px; } #disqus-box:hover {     background: #164b78; } #disqus-pre {     position: relative; padding: 40px 0px;  } </style>  <div class='popzone'>     <div id='disqus_thread'>         <div id='disqus-box'>             <div id='disqus-pre'>Show / Write Comments</div>         </div>     </div> </div>  <script>     var disqus_publickey = "Your_Disqus_API_Public_Key";     var disqus_shortname = "Your_Disqus_Shortname";     var disqus_blogger_current_url = "<data:blog.canonicalUrl/>";     var thread_url = 'link:' + disqus_blogger_current_url;      $.ajax({         type: 'GET',         url: 'https://disqus.com/api/3.0/threads/set.jsonp',         data: { api_key: disqus_publicKey, forum: disqus_shortname, thread: thread_url },         cache: false,         dataType: 'jsonp',         success: function(result) {             if (result.response.length === 1) {                 divText = 'Show Comments [' + result.response[0].posts + ']';                 if (result.response[0].posts == "0") {                     $('#disqus-pre').html("Write Comment");                 } else {                     $('#disqus-pre').html(divText);                 }             }         }     });       var disqus_config = function () {         this.callbacks.onReady = [function(data) {             $("#disqus-box").delay(300).fadeOut();         }];     };       $('#disqus-box').on('click', function(){         $.ajax({             type: 'GET',             url: '//' + disqus_shortname + '.disqus.com/blogger_item.js',             dataType: 'script',             cache: true         }); $('#disqus-pre').html("Loading Comment Box...");     });      if(/\#comment/.test(location.hash)){         $('#disqus-box').trigger('click');     }  </script> </b:if> <!-- Disqus Code End --> 

Explanation :
Script require an disqus_publickey, disqus_shortname to be filled, while thread_url is value from our page canonical url. There is blogger_item.js not embed.js for blogger, which require disqus_blogger_current_url. Script will make an ajax call to get post count result. If response is "0" then text inside div with id disqus-pre will be overriden by text "Write Comment" else it will show an text Show Comment [num_post_count]. if the post has just been created, result will show nothing, exept someone open that box, and there is delay before count show result, so we fill with text "Show / Write Comments in it. If someone post an comment after reload, instantly we will get count result.

Script then give #disqus-box div have an function when clicked. It will replace all text inside to "Loading Comment Box...", when callback disqus on ready state, div block will disappear after 300ms. At the end, if url has #comment then #disqus-box div will simulating click event.

You will get more detail of you se post Disqus Comment on Click with Counter Comment Count. If you looking for Disqus Lazyload Method, see post Lazyload Disqus Comment on Blogger Site

Sumber https://www.blakbin.com/

Selain sebagai media informasi pendidikan, kami juga berbagi artikel terkait bisnis.

Komentar

Postingan populer dari blog ini

Aturan Input Nomor Registrasi Akta Kelahiran di Dapodik Versi 2016

Jangan lupa membaca artikel tentang bisnis di > Informasi bisnis terbaik 2020 . Aturan Input Nomor Registrasi Akta Kelahiran di Dapodik . Aplikasi Dapodik Versi 2016 yang dirilis Ditjen Dikdasmen (Direktorat Jendral Pendidikan Dasar dan Menengah) dibuat dengan format baru. Mulai dari tampilan, menu aplikasi hingga beberapa pembaruan sistem telah dilakukan. Untuk itu, sebagai seorang operator anda perlu mengetahui semua jenis pembaruan aplikasi yang resmi dirilis ini. Mengapa harus demikian? Sebab ada beberapa pembaruan yang sangat penting dan wajib diisi. Apabila tidak dilakukan, maka yang terjadi adalah saat melakukan validasi data akan muncul peringatan Invalid. Jenis peringatan ini berarti bahwa ada data utama yang belum diisi atau diisi tetapi masih salah. Sehingga anda tidak akan bisa melakukan sinkronisasi data selama hal itu belum diperbaiki sesuai dengan juknis penggunaan aplikasi. Aturan Input Nomor Registrasi Akta Kelahiran di Dapodik. Pasti anda sudah mengerti ak...

CONTOH SK KRITERIA KENAIKAN KELAS DAN KELULUSAN

Jangan lupa membaca artikel tentang bisnis di > Informasi bisnis terbaik 2020 . KOP MADRASAH SURAT KEPUTUSAN No. ……………………… Tentang KRITERIA KENAIKAN KELAS DAN KELULUSAN A. Mekanisme Kenaikan Kelas 1)       Penentuan siswa yang naik dan tidak naik ditetapkan pada rapat antara kepala madrasah dan dewan guru. 2)       Pertimbangan kenaikan kelas bagi siswa didasarkan pada kriteria kenaikan kelas, presensi siswa, kelakuan atau sikap siswa yang bersangkutan. 3)       Siswa yang dinyatakan naik kelas, rapornya dituliskan naik ke kelas berikutnya. 4)       Siswa yang dinyatakan tidak naik kelas harus mengulang di kelas yang sama. 5)       Rapor kenaikan kelas dinyatakan sah apabila telah ditandatangani oleh wali kelas dan kepala madrasah. 6)       Bagi siswa yang naik kelas tetapi belum tuntas pada mata pelajaran te...

Kombinasi Warna Orange Muda

Jangan lupa membaca artikel tentang bisnis di > Informasi bisnis terbaik 2020 . Kombinasi Warna Orange Muda  | Setiap orang pasti memiliki selera masing - masing, semua itu adalah hal yang mutlak. seperti selera warna, menurut desainer semua manusia pasti memiliki warna favorit, karena dengan warna kesukaan kita bisa merasakan hal yang membuat perasaan jadi tenang dan damai. untuk pertemuankali ini, kita akan membahas tentang warna orange muda, serta penerapan kombinasi warna orange muda pada desain. Warna Orange Muda Apa itu warna orange muda ? Warna orange muda adalah warna orange yang sudah diberikan penerangan, dengan cara dicampurkan warna putih sehingga kelihatan lebih cerah. warna orange muda tergolong warna pastel sebab warna pastel adalah kategori warna muda. Warna orange juga memiliki arti yaitu menunjukan antusiasme, persahabatan, suatu pencapaian, kesuksesan, kesehatan pikiran dan kehangatan. ini semua diambil dari hasil uji laboratorium, pengaruh warna orange terhad...