Cara Memperbaiki Tombol Reply Pada Blogger Yang Tidak Berfungsi


Halo blogger Indonesia, saya yakin pasti anda semua pernah mengalami hal serupa yang pernah saya alami, mengoptimalisasi tampilan blog sudah pasti sering dilakukan bukan ?

Namun pasti anda merasa cemas dan sempat kesal apalagi salah satu fungsi yang lumayan penting untuk interaksi dengan pengunjung blog, yaitu tombol reply pada form komentar tidak berfungsi sesuai dengan harapan, nah kali ini saya punya sedikit pengalaman yang mungkin akan bermanfaat bagi kawan semua.

Tanpa basa-basi lagi  :
1. Anda Login ke akun blogger anda-->kemudian klik template-->Edit Html-->Jangan lupa centang pada Expand Template Widgets. (Sebelumnya anda unduh lengkap template anda terlebih dahulu,,Penting!!).
2. Kemudian anda cari kode berikut :
<b:includable id='threaded_comment_js' var='post'><br>   <script defer='defer' expr:src='data:post.commentSrc' type='text/javascript'/><br> <br>   <script type='text/javascript'><br>     (function() {<br>       var items = <data:post.commentJso/>;<br>       var msgs = <data:post.commentMsgs/>;<br>       var postId = '<data:post.id/>';<br>       var feed = '<data:post.commentFeed/>';<br>       var authorName = '<data:post.author/>';<br>       var authorUrl = '<data:post.authorUrl/>';<br>       var blogId = '<data:top.id/>';<br>       var baseUri = '<data:post.commentBase/>';<br> <br> // <![CDATA[<br>       feed += '?alt=json&v=2&orderby=published&reverse=false&max-results=50';<br>       var cursor = null;<br>       if (items && items.length > 0) {<br>         cursor = parseInt(items[items.length - 1].timestamp) + 1;<br>       }<br> <br>       var bodyFromEntry = function(entry) {<br>         if (entry.gd$extendedProperty) {<br>           for (var k in entry.gd$extendedProperty) {<br>             if (entry.gd$extendedProperty[k].name == 'blogger.contentRemoved') {<br>               return '<span class="deleted-comment">' + entry.content.$t + '</span>';<br>             }<br>           }<br>         }<br>         return entry.content.$t;<br>       }<br> <br>       var parse = function(data) {<br>         cursor = null;<br>         var comments = [];<br>         if (data && data.feed && data.feed.entry) {<br>           for (var i = 0, entry; entry = data.feed.entry[i]; i++) {<br>             var comment = {};<br>             // comment ID, parsed out of the original id format<br>             var id = /blog-(\d+).post-(\d+)/.exec(entry.id.$t);<br>             comment.id = id ? id[2] : null;<br>             comment.body = bodyFromEntry(entry);<br>             comment.timestamp = Date.parse(entry.published.$t) + '';<br>             if (entry.author && entry.author.constructor === Array) {<br>               var auth = entry.author[0];<br>               if (auth) {<br>                 comment.author = {<br>                   name: (auth.name ? auth.name.$t : undefined),<br>                   profileUrl: (auth.uri ? auth.uri.$t : undefined),<br>                   avatarUrl: (auth.gd$image ? auth.gd$image.src : undefined)<br>                 };<br>               }<br>             }<br>             if (entry.link) {<br>               if (entry.link[2]) {<br>                 comment.link = comment.permalink = entry.link[2].href;<br>               }<br>               if (entry.link[3]) {<br>                 var pid = /.*comments\/default\/(\d+)\?.*/.exec(entry.link[3].href);<br>                 if (pid && pid[1]) {<br>                   comment.parentId = pid[1];<br>                 }<br>               }<br>             }<br>             comment.deleteclass = 'item-control blog-admin';<br>             if (entry.gd$extendedProperty) {<br>               for (var k in entry.gd$extendedProperty) {<br>                 console.log(entry.gd$extendedProperty[k].name + ' - ' + entry.gd$extendedProperty[k].value);<br>                 if (entry.gd$extendedProperty[k].name == 'blogger.itemClass') {<br>                   comment.deleteclass += ' ' + entry.gd$extendedProperty[k].value;<br>                 }<br>               }<br>             }<br>             comments.push(comment);<br>           }<br>         }<br>         return comments;<br>       };<br> <br>       var paginator = function(callback) {<br>         if (hasMore()) {<br>           var url = feed;<br>           if (cursor) {<br>             url += '&published-min=' + new Date(cursor).toISOString();<br>           }<br>           window.bloggercomments = function(data) {<br>             var parsed = parse(data);<br>             cursor = parsed.length < 50 ? null<br>                 : parseInt(parsed[parsed.length - 1].timestamp) + 1<br>             callback(parsed);<br>             window.bloggercomments = null;<br>           }<br>           url += '&callback=bloggercomments';<br>           var script = document.createElement('script');<br>           script.type = 'text/javascript';<br>           script.src = url;<br>           document.getElementsByTagName('head')[0].appendChild(script);<br>         }<br>       };<br>       var hasMore = function() {<br>         return !!cursor;<br>       };<br>       var getMeta = function(key, comment) {<br>         if ('iswriter' == key) {<br>           var matches = !!comment.author<br>               && comment.author.name == authorName<br>               && comment.author.profileUrl == authorUrl;<br>           return matches ? 'true' : '';<br>         } else if ('deletelink' == key) {<br>           return baseUri + '/delete-comment.g?blogID=' + blogId + '&postID=' + comment.id;<br>         } else if ('deleteclass' == key) {<br>           return comment.deleteclass;<br>         }<br>         return '';<br>       };<br> <br>       var replybox = null;<br>       var replyUrlParts = null;<br>       var replyParent = undefined;<br> <br>       var onReply = function(commentId, domId) {<br>         if (replybox == null) {<br>           // lazily cache replybox, and adjust to suit this style:<br>           replybox = document.getElementById('comment-editor');<br>           if (replybox != null) {<br>             replybox.height = '250px';<br>             replybox.style.display = 'block';<br>             replyUrlParts = replybox.src.split('#');<br>           }<br>         }<br>         if (replybox && (commentId !== replyParent)) {<br>           document.getElementById(domId).insertBefore(replybox, null);<br>           replybox.src = replyUrlParts[0]<br>               + (commentId ? '&parentID=' + commentId : '')<br>               + '#' + replyUrlParts[1];<br>           replyParent = commentId;<br>         }<br>       };<br> <br>       var tok = 'comment-form_';<br>       var hash = window.location.hash || '';<br>       var startThread = hash.indexOf(tok) == 1 ? hash.substring(tok.length + 1) : undefined;<br> <br>       // Configure commenting API:<br>       var configJso = {<br>         'maxDepth': 2<br>       };<br>       var provider = {<br>         'id': postId,<br>         'data': items,<br>         'loadNext': paginator,<br>         'hasMore': hasMore,<br>         'getMeta': getMeta,<br>         'onReply': onReply,<br>         'rendered': true,<br>         'initReplyThread': startThread,<br>         'config': configJso,<br>         'messages': msgs<br>       };<br> <br>       var render = function() {<br>         if (window.goog && window.goog.comments) {<br>           var holder = document.getElementById('comment-holder');<br>           window.goog.comments.render(holder, provider);<br>         }<br>       };<br> <br>       // render now, or queue to render when library loads:<br>       if (window.goog && window.goog.comments) {<br>         render();<br>       } else {<br>         window.goog = window.goog || {};<br>         window.goog.comments = window.goog.comments || {};<br>         window.goog.comments.loadQueue = window.goog.comments.loadQueue || [];<br>         window.goog.comments.loadQueue.push(render);<br>       }<br>     })();<br> // ]]><br>   </script><br> </b:includable>

3. Jika anda sudah menemukannya, maka ganti kode di atas dengan kode berikut :


<b:includable id='threaded_comment_js' var='post'><br /> <script async='async' expr:src='data:post.commentSrc' type='text/javascript'/> <script type='text/javascript'> (function() { var items = <data:post.commentJso/>; var msgs = <data:post.commentMsgs/>; var config = <data:post.commentConfig/>; // <![CDATA[ var cursor = null; if (items && items.length > 0) { cursor = parseInt(items[items.length - 1].timestamp) + 1; } var bodyFromEntry = function(entry) { if (entry.gd$extendedProperty) { for (var k in entry.gd$extendedProperty) { if (entry.gd$extendedProperty[k].name == 'blogger.contentRemoved') { return '<span class="deleted-comment">' + entry.content.$t + '</span>'; } } } return entry.content.$t; } var parse = function(data) { cursor = null; var comments = []; if (data && data.feed && data.feed.entry) { for (var i = 0, entry; entry = data.feed.entry[i]; i++) { var comment = {}; // comment ID, parsed out of the original id format var id = /blog-(\d+).post-(\d+)/.exec(entry.id.$t); comment.id = id ? id[2] : null; comment.body = bodyFromEntry(entry); comment.timestamp = Date.parse(entry.published.$t) + ''; if (entry.author && entry.author.constructor === Array) { var auth = entry.author[0]; if (auth) { comment.author = { name: (auth.name ? auth.name.$t : undefined), profileUrl: (auth.uri ? auth.uri.$t : undefined), avatarUrl: (auth.gd$image ? auth.gd$image.src : undefined) }; } } if (entry.link) { if (entry.link[2]) { comment.link = comment.permalink = entry.link[2].href; } if (entry.link[3]) { var pid = /.*comments\/default\/(\d+)\?.*/.exec(entry.link[3].href); if (pid && pid[1]) { comment.parentId = pid[1]; } } } comment.deleteclass = 'item-control blog-admin'; if (entry.gd$extendedProperty) { for (var k in entry.gd$extendedProperty) { if (entry.gd$extendedProperty[k].name == 'blogger.itemClass') { comment.deleteclass += ' ' + entry.gd$extendedProperty[k].value; } } } comments.push(comment); } } return comments; }; var paginator = function(callback) { if (hasMore()) { var url = config.feed + '?alt=json&v=2&orderby=published&reverse=false&max-results=50'; if (cursor) { url += '&published-min=' + new Date(cursor).toISOString(); } window.bloggercomments = function(data) { var parsed = parse(data); cursor = parsed.length < 50 ? null : parseInt(parsed[parsed.length - 1].timestamp) + 1 callback(parsed); window.bloggercomments = null; } url += '&callback=bloggercomments'; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = url; document.getElementsByTagName('head')[0].appendChild(script); } }; var hasMore = function() { return !!cursor; }; var getMeta = function(key, comment) { if ('iswriter' == key) { var matches = !!comment.author && comment.author.name == config.authorName && comment.author.profileUrl == config.authorUrl; return matches ? 'true' : ''; } else if ('deletelink' == key) { return config.baseUri + '/delete-comment.g?blogID=' + config.blogId + '&postID=' + comment.id; } else if ('deleteclass' == key) { return comment.deleteclass; } return ''; }; var replybox = null; var replyUrlParts = null; var replyParent = undefined; var onReply = function(commentId, domId) { if (replybox == null) { // lazily cache replybox, and adjust to suit this style: replybox = document.getElementById('comment-editor'); if (replybox != null) { replybox.height = '250px'; replybox.style.display = 'block'; replyUrlParts = replybox.src.split('#'); } } if (replybox && (commentId !== replyParent)) { document.getElementById(domId).insertBefore(replybox, null); replybox.src = replyUrlParts[0] + (commentId ? '&parentID=' + commentId : '') + '#' + replyUrlParts[1]; replyParent = commentId; } }; var hash = (window.location.hash || '#').substring(1); var startThread, targetComment; if (/^comment-form_/.test(hash)) { startThread = hash.substring('comment-form_'.length); } else if (/^c[0-9]+$/.test(hash)) { targetComment = hash.substring(1); } // Configure commenting API: var configJso = { 'maxDepth': config.maxThreadDepth }; var provider = { 'id': config.postId, 'data': items, 'loadNext': paginator, 'hasMore': hasMore, 'getMeta': getMeta, 'onReply': onReply, 'rendered': true, 'initComment': targetComment, 'initReplyThread': startThread, 'config': configJso, 'messages': msgs }; var render = function() { if (window.goog && window.goog.comments) { var holder = document.getElementById('comment-holder'); window.goog.comments.render(holder, provider); } }; // render now, or queue to render when library loads: if (window.goog && window.goog.comments) { render(); } else { window.goog = window.goog || {}; window.goog.comments = window.goog.comments || {}; window.goog.comments.loadQueue = window.goog.comments.loadQueue || []; window.goog.comments.loadQueue.push(render); } })(); // ]]> </script><br /> </b:includable>


4. Terakhir anda simpan template. Jika anda berhasil melakukannya sesuai prosedur, maka fungsi reply seharusnya sudah normal kembali.

Catatan :
Mungkin saja kode html pada no 1 tidak akan sama persis, yang paling penting cari saja yang mirip kodenya, yang harus anda perhatikan kode di atas di awali dengan <b:includable id='threaded_comment_js' var='post'> dan diakhiri dengan kode </b:includable>


Comments

Posting Komentar