function advanced_forum_first_new_post_link in Advanced Forum 6
Same name and namespace in other branches
- 5 advanced_forum.module \advanced_forum_first_new_post_link()
- 6.2 advanced_forum.module \advanced_forum_first_new_post_link()
- 7.2 advanced_forum.module \advanced_forum_first_new_post_link()
Returns a link directly to the first new post in a topic.
Parameters
$node: Node object
$comment_count: Number of comments on passed node.
Return value
Link to the first unread comment with text as "42 new".
1 call to advanced_forum_first_new_post_link()
- advanced_forum_preprocess_advanced_forum_topic_header in ./
advanced_forum.module - Preprocesses template variables for the topic header template.
File
- ./
advanced_forum.module, line 1621 - Enables the look and feel of other popular forum software.
Code
function advanced_forum_first_new_post_link($node, $comment_count) {
$nid = $node->nid;
$current_page = !empty($_GET['page']) ? "page=" . $_GET['page'] : 0;
$number_new_comments = comment_num_new($nid);
if ($number_new_comments > 0) {
// Note that we are linking to the cid anchor rather than "new" because
// the new links will be gone if we go to another page.
$page_of_first_new = comment_new_page_count($comment_count, $number_new_comments, $node);
$cid_of_first_new = advanced_forum_first_new_comment($nid);
return l($number_new_comments . ' ' . t('new'), 'node/' . $nid, array(
'query' => $page_of_first_new,
'fragment' => "comment-{$cid_of_first_new}",
));
}
}