Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solution: News Manager & External Commenting Working Together
#6
This is a Disqus-only fix:

To preview a post's comment count on excerpt page/s and at the top of each post, paste the following into your /theme/ThemeName/template.php (or equivalent) file just before the </body> tag:

Code:
<script type="text/javascript">
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'example'; // required: replace example with your forum shortname

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function () {
        var s = document.createElement('script'); s.async = true;
        s.type = 'text/javascript';
        s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
        (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
    }());
</script>

Next, add the following where desired to your newsmanager/inc/site.php file:
Code:
<span class="disqus_comment_count"><a href="<?php echo $url; ?>#disqus_thread" data-disqus-identifier="<?php echo $slug; ?>">&nbsp;</a></span>

Context:
Code:
/*******************************************************
* @function nm_show_post
* param $slug post slug
* param $excerpt - if TRUE, print only a short summary
* @action show the requested post on front-end news page
*/
function nm_show_post($slug, $excerpt=false) {
  $file = NMPOSTPATH . "$slug.xml";
  $post = @getXML($file);
  if (!empty($post) && $post->private != 'Y') {
    $url     = nm_get_url('post') . $slug;
    $title   = strip_tags(strip_decode($post->title));
    $date    = nm_get_date(i18n_r('news_manager/DATE_FORMAT'), strtotime($post->date));
    $content = strip_decode($post->content);
    if ($excerpt) $content = nm_create_excerpt($content);
    # print post data ?>
    <div class="nm_post">
      <h3 class="nm_post_title">
        <a href="<?php echo $url; ?>"><?php echo $title; ?></a>
      </h3><span class="disqus_comment_count"><a href="<?php echo $url; ?>#disqus_thread" data-disqus-identifier="<?php echo $slug; ?>">&nbsp;</a></span>
      <p class="nm_post_date"><?php echo i18n_r('news_manager/PUBLISHED') . " $date"; ?></p>
      <div class="nm_post_content"><?php echo $content; ?></div>

Result:

[Image: 2sl1o.png]
Reply


Messages In This Thread
Solution: News Manager & External Commenting Working Together - by jsmcgraw - 2012-02-20, 07:53:48



Users browsing this thread: 1 Guest(s)