You are here

function advanced_forum_last_post_link in Advanced Forum 7.2

Same name and namespace in other branches
  1. 5 advanced_forum.module \advanced_forum_last_post_link()
  2. 6.2 advanced_forum.module \advanced_forum_last_post_link()
  3. 6 advanced_forum.module \advanced_forum_last_post_link()

Get a link to the last post in a topic.

Parameters

object $node: Node object

Return value

string Text linking to the last post in a topic.

1 call to advanced_forum_last_post_link()
advanced_forum_preprocess_advanced_forum_topic_header in includes/theme.inc
Preprocesses template variables for the topic header template.

File

./advanced_forum.module, line 932
Enables the look and feel of other popular forum software.

Code

function advanced_forum_last_post_link($node) {
  $last_comment_id = advanced_forum_last_post_in_topic($node->nid);

  // Return empty link if post doesn't have comments.
  if (empty($last_comment_id)) {
    return '';
  }
  $last_page = advanced_forum_get_last_page($node);
  if ($last_page > 0) {
    $query = array(
      'page' => $last_page,
    );
  }
  $options = array(
    'html' => TRUE,
    'query' => empty($query) ? array() : $query,
    'fragment' => "comment-{$last_comment_id}",
  );
  return theme('advanced_forum_l', array(
    'text' => t('Last post'),
    'path' => "node/{$node->nid}",
    'options' => $options,
    'button_class' => 'large',
  ));
}