Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solution: News Manager & External Commenting Working Together
#1
In reading through the forums, it seems some of the information out there on this topic is a bit out of date so I thought I'd add my piece.

Currently, it is suggested (via combining the information on the External Commenting install page and the support thread) that the following be appended to the /inc/site.php file (at the end of the nm_show_post function) in the News Manager plugin to get things working:

Code:
get_external_comments($id, $url, $title);

However, this results in comments to one post appearing on all the posts. Instead, append this:

Code:
get_external_comments($slug, $url, $title);

Context:
Code:
<div class="nm_post">
      <h3 class="nm_post_title">
        <a href="<?php echo $url; ?>"><?php echo $title; ?></a>
      </h3>
      <p class="nm_post_date"><?php echo i18n_r('news_manager/PUBLISHED') . " $date"; ?></p>
      <div class="nm_post_content"><?php echo $content; ?></div>
      <?php
      # print tags, if any
      if (!empty($post->tags)) {
        echo '<p class="nm_post_meta"><b>' . i18n_r('news_manager/TAGS') . ':</b>';
        $tags = explode(',', $post->tags);
        foreach ($tags as $tag) {
          $url = nm_get_url('tag') . $tag;
          echo " <a href=\"$url\">$tag</a>";
        }
        echo '</p>';
        }
        # added to display a comment box via the External Comments Plugin
        get_external_comments($slug, $url, $title);
        # show "go back" link, if required
      if (strstr($_SERVER['QUERY_STRING'], "post=$slug")) {
        echo '<p class="nm_post_back"><a href="javascript:history.back()">&lt;&lt; ';
        i18n('news_manager/GO_BACK');
        echo '</a></p>';
      }
      ?>

For sites where multiple post excerpts are featured on the news page, getting external commenting working introduces the problem of scads of conflicting comment boxes loading up on a single page. To clean up the mess and have the comment boxes appear only on discrete post pages instead of beneath excerpts, it is necessary to prevent the external comments from loading when the excerpts are generated. To do so, ignore what I've written above and instead append the following to the /inc/site.php file of the News Manager plugin:

Code:
<?php if ($excerpt==false) echo get_external_comments($slug, $url, $title); ?>

Context:
Code:
# show "go back" link, if required
if (strstr($_SERVER['QUERY_STRING'], "post=$slug")) {
        echo '<p class="nm_post_back"><a href="javascript:history.back()">&lt;&lt; ';
        i18n('news_manager/GO_BACK');
        echo '</a></p>';
      }
      ?>
<?php
if ($excerpt==false) echo get_external_comments($slug, $url, $title); ?>
    </div>
    <?php
  } else {
    echo '<p>' . i18n_r('news_manager/NOT_EXIST') . '</p>';
  }

}
Reply
#2
Another issue when configuring NewsManager to turn GS into a blog is that the excerpts on the news page (i.e. whatever is configured to be the front page) ignore formatting tags, resulting in a wall-of-text for longer excerpts. To address this, open the NewsManager file /inc/functions.php and remove this line from the nm_create_slug function:

Code:
$content = strip_tags($content);

Before:
Code:
/*******************************************************
* @function nm_create_excerpt
* @param $content the post content
* @return a truncated version of the post content
*/
function nm_create_excerpt($content) {
  global $NMEXCERPTLENGTH;
  $len = intval($NMEXCERPTLENGTH);
  $content = strip_tags($content);
  if (strlen($content) > $len) {
    if (function_exists('mb_substr'))
      $content = trim(mb_substr($content, 0, $len, 'UTF-8')) . ' [...]';
    else
      $content = trim(substr($content, 0, $len)) . ' [...]';
  }
  return "<p>$content</p>";
}

After:
Code:
/*******************************************************
* @function nm_create_excerpt
* @param $content the post content
* @return a truncated version of the post content
*/
function nm_create_excerpt($content) {
  global $NMEXCERPTLENGTH;
  $len = intval($NMEXCERPTLENGTH);
   if (strlen($content) > $len) {
    if (function_exists('mb_substr'))
      $content = trim(mb_substr($content, 0, $len, 'UTF-8')) . ' [...]';
    else
      $content = trim(substr($content, 0, $len)) . ' [...]';
  }
  return "<p>$content</p>";
}
Reply
#3
jsmcgraw Wrote:Another issue when configuring NewsManager to turn GS into a blog is that the excerpts on the news page (i.e. whatever is configured to be the front page) ignore formatting tags, resulting in a wall-of-text for longer excerpts. To address this, open the NewsManager file /inc/functions.php and remove this line from the nm_create_slug function:

Code:
$content = strip_tags($content);

This will create invalid HTML code in most cases.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#4
This is the issue I have on one of my sites and not found an answer yet to have the [...] as a continuation of the post and also to remove the formatting errors out of it.

http://www.peteberry.co.uk

Someone come up with the answer and its blog heaven Smile
Pete

Chefbyte Services
Reply
#5
Quote:This will create invalid HTML code in most cases.

Hmmm... I do see that now... but I've yet to find a browser for which it is a problem so I'll have to revisit later as the greater problem at the moment is lack of formatting.

Any suggested alternative?
Reply
#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
#7
mvlcek Wrote:This will create invalid HTML code in most cases.

Funny thing is I can see extra <p> tags at the beginning of each excerpt but they have no effect, links and formatting work, and it's even able to pass the W3 Validator.
Reply
#8
chefbyte Wrote:This is the issue I have on one of my sites and not found an answer yet to have the [...] as a continuation of the post

I wasn't able to replace the "[...]" at the excerpt's truncation but I did come up with a little workaround to lead readers to the full post at the end of the excerpt. In the NewsManager /inc/site.php file, I added this:

Code:
<div style="float:right;margin-top:-25px;">
        <?php if ($excerpt==true) echo " <a href=\"$url\">Read full article</a>"; ?></div></div>
         <div style="clear:both;"><p>&nbsp;</p></div>

The float & margin put it just below the text on the right hand side while the clearing div & empty paragraph create some whitespace.

In context:

Code:
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 style="float:right;margin-top:-25px;">
        <?php if ($excerpt==true) echo " <a href=\"$url\">Read full article</a>"; ?></div></div>
         <div style="clear:both;"><p>&nbsp;</p></div>
      <?php
      # print tags, if any
      if (!empty($post->tags)) {
        echo '<p class="nm_post_meta"><b>' . i18n_r('news_manager/TAGS') . ':</b>';
        $tags = explode(',', $post->tags);
        foreach ($tags as $tag) {
          $url = nm_get_url('tag') . $tag;
          echo " <a href=\"$url\">$tag</a>";
        }
        echo '</p>';
        }
Reply
#9
Thanks for the tip, that's added a link to the full article. bit of extra white space now between the posts but I will figure it out when I get second.
Pete

Chefbyte Services
Reply
#10
if you don't want to have the "[...]", you can simply write something else in it or let it empty in "functions.php":

Code:
/*******************************************************
* @function nm_create_excerpt
* @param $content the post content
* @return a truncated version of the post content
*/
/*function nm_create_excerpt($content) {
  global $NMEXCERPTLENGTH;
  $len = intval($NMEXCERPTLENGTH);
  $content = strip_tags($content);
  if (strlen($content) > $len) {
    if (function_exists('mb_substr'))
      $content = trim(mb_substr($content, 0, $len, 'UTF-8')) . ' [...]';  /*  <- here */
    else
      $content = trim(substr($content, 0, $len)) . ' [...]'; /* <- here */
  }
  return "<p>$content</p>";
Reply
#11
declis Wrote:if you don't want to have the "[...]", you can simply write something else in it or let it empty in "functions.php":

Indeed. But what I (and I think chefbyte) meant was that we could not replace the [...] with a link to the full post. I could not create a string that would work in the context of the function and had to put it elsewhere.
Reply
#12
oh yeah, that's right! i tried it also and found your solution here in the thread. everything's working fine (comments count and the "read more" link), thanks!
Reply
#13
@jsmcgraw
thanks for comments count.working fine
Reply
#14
Hi there, I have one problem with those two plugins working together.

When two or more posts have same tags, facebook coments is shown on all posts. For example if I comment one post with facebook, that comment is apear on all posts with same tag.

Can someone help please?
Reply
#15
I want thumnail(Picture) system like wordpress. Is it difficult? You have to change control panel , maybe...
Reply




Users browsing this thread: 1 Guest(s)