DISQUS

DISQUS Hello! DISQUS Blog and Forum is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

DISQUS Blog and Forum

The official Disqus forum. This is the place to receive beta support and offer suggestions.
« Back
Author

A thread per-article from a blog?

Started by inode · 1 year ago

I'm using the generic code snippet for my blog page (created with nanoblogger), and on my index page I have 5 different articles, and 5 disqus blocks - however each one is displaying the same content ...

What do I need to do to make each one track a different thread, based I guess on a unique article identifier ... probably the permalink URL?

6 comments

  • Hi inode,

    Yup, the unique article identifier is the URL. Each new URL is a different
    thread on Disqus.

    Let me know if you need anything.
  • The clue is a start, but a slightly targetted example would be better!

    This is the blog template code at the moment :-

    < div class="posted">
    < br />$template_postedby < span class="item-creator">$NB_EntryAuthor< /span>
    $([ "$PERMALINKS" = "1" ] && echo '| < a class="link" href="'${ARCHIVES_PATH}$NB_EntryPermalink'" rel="nofollow">'$template_permlink'< /a>')
    $([ ! -z "$NB_EntryCategories" ] && echo "| $template_catlinks $NB_EntryCategories" |sed -e '{$ s/\,$//; }')
    < div id="disqus_thread">< /div>< script type="text/javascript" src="http://disqus.com/forums/notabene/embed.js">< /script>< noscript>< a href="http://notabene.disqus.com/?url=ref" rel="nofollow">View the forum thread.< /a>< /noscript>
    < /div>

    So you can see that the URL of the article itself will be '${ARCHIVES_PATH}$NB_EntryPermalink'

    However the Disqus code is purely generated by <script type="text/javascript" src="http://disqus.com/forums/notabene/embed.js"></script> and I don't know how to pass parameters into that (I'm not much of a javascript person)

    I've grabbed that script, and it seems as if the implied link is coming via :-
    var disqus_href = window.location.href;
    This gets built up into disqus_url, which is passed into thread.js ...
    disqus_script.src = 'http://disqus.com/forums/notabene/thread.js'
    + '?url=' + encodeURI(disqus_url)


    Do you think I should grab a local copy of embed.js and modify that, instead of using the one hosted on disqus? I don't think that's a good strategy as I'm sure to miss any development work that will go into that script over time ...

    Or is there something else I've missed?
  • You can pass the permalink of each post to the script as such:

    <script type="text/javascript">
      var disqus_url = '$PERMALINK';
    </script>
    <!-- General JavaScript snippet goes here -->

    One thing I've noticed on your blog is that permalinks anchor to the post, though we ignore anchors for permalinks. You can overcome that if you change the links to a query string when you pass it into disqus_url above. (e.g., set disqus_url to http://nb.inode.co.nz/archives/2007/10/31/index.html?e2007-10-31T11_05_34.txt -- the change I made was replacing '#' with '?' in your permanent link.)
  • Yeah, some of the linking is odd -- it basically puts all blog entries from the same day on the same page, hence the anchoring to identify which one you want.

    At this stage I think I'll have to 'ignore' this, certainly it isn't disqus' fault :-)

    Thanks for that code snippet, now I know what to look for in embed.js I see the whole "if undefined" set of code :-) Some more stuff to play with!
  • Thanks for your help -- all working now!
    http://nb.inode.co.nz/archives/2007/11/09/index...
  • Sweet!

Add New Comment

Returning? Login