News Manager blog

Patch: store and display post author in News Manager

Edit news_manager/inc/posts.php, find this:
Code:
$obj = $xml->addChild('content');
$obj->addCData($content);
Just after that, insert this:
Code:
// patch (author)
  if (isset($_POST['author'])) {
    $author = safe_slash_html($_POST['author']);
  } else {
    global $USR;
    if ($USR) $author = $USR;
  }
  if (isset($author)) {
    $obj = $xml->addChild('author');
    $obj->addCData($author);
  }
  // end patch (author)

Now edit news_manager/inc/site.php, find this:
Code:
if ($excerpt) $content = nm_create_excerpt($content);
Just after that, insert this:
Code:
$author = isset($post->author) ? stripslashes($post->author) : 'default_author'; // patch (author)
(change that default_author string by the name you want to be displayed in posts created before this patch)

And also in site.php, some lines below, insert <?php echo $author; ?> to display the user name.
For example, you could replace this:
Code:
<p class="nm_post_date"><?php echo i18n_r('news_manager/PUBLISHED') . " $date"; ?></p>
by this:
Code:
<p class="nm_post_date"><?php echo i18n_r('news_manager/PUBLISHED') . " $date"; ?> by <?php echo $author; ?></p>

As always, you'll have to re-do these patches when/if you upgrade the plugin.

The most important is the first one (posts.php) - if you don't do it and update some existing post, its author field will be lost.

(First posted here: http://get-simple.info/forums/showthread.php?tid=3972&pid=36643#pid36643 )

« Back to News Manager blog

blog comments powered by Disqus