Posted by ixeft on March 25, 2008 at 8:35pm
Jump to:
| Project: | Advanced Forum |
| Version: | 5.x-1.x-dev |
| Component: | User interface |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Hello,
in the forum list we can view went they are new node but we can't view went they are new comment...
Thank you for your work
Comments
#1
I don't understand this one.. When there's a new comment, it shows up as "N new". What is it you're wanting to see?
Michelle
#2
in global forum list :
- when they's new topic, it show up as "N new"
- when there's new comment, it's not show up as "N new" (that's the problem!)
in topic list :
- when there's new comment, it's show up as "N new"
I tried to explain better but I don't speak english very well, sorry ^^
Thank you!
#3
I think I got it:
On the global list "N new" stands for
N new or updated topics
on a boards list "N new" stands for
N comments
#4
ok! I have find solution, it need some modification in d6_compat.inc and advf-forum-list.tpl.php
in d6_compat.inc (l.124) :
<?php
/* ADDED FUNCTION */
function _forum_comments_unread($term, $uid) {
$sql = "SELECT COUNT(c.cid) FROM {comments} c INNER JOIN {node} n INNER JOIN {term_node} tn ON c.nid = n.nid AND c.nid = tn.nid AND tn.tid = %d LEFT JOIN {history} h ON c.nid = h.nid AND h.uid = %d WHERE n.status = 1 AND n.type = 'forum' AND c.timestamp > h.timestamp";
$sql = db_rewrite_sql($sql);
return db_result(db_query($sql, $term, $uid, NODE_NEW_LIMIT));
}
/*UPDATED FUNCTION */
function template_preprocess_forum_list(&$variables) {
global $user;
$row = 0;
// Sanitize each forum so that the template can safely print the data.
foreach ($variables['forums'] as $id => $forum) {
$variables['forums'][$id]->description = !empty($forum->description) ? filter_xss_admin($forum->description) : '';
$variables['forums'][$id]->link = url("forum/$forum->tid");
$variables['forums'][$id]->name = check_plain($forum->name);
$variables['forums'][$id]->is_container = !empty($forum->container);
$variables['forums'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even';
$row++;
$variables['forums'][$id]->new_text = '';
$variables['forums'][$id]->new_url = '';
$variables['forums'][$id]->new_topics = 0;
$variables['forums'][$id]->old_topics = $forum->num_topics;
/*added line*/
$variables['forums'][$id]->new_posts = 0;
$variables['forums'][$id]->new_text_posts = '';
$variables['forums'][$id]->new_url_posts = '';
$variables['forums'][$id]->old_posts = $forum->num_posts;
/* and of added line*/
if ($user->uid) {
$variables['forums'][$id]->new_topics = _forum_topics_unread($forum->tid, $user->uid);
if ($variables['forums'][$id]->new_topics) {
$variables['forums'][$id]->new_text = format_plural($variables['forums'][$id]->new_topics, '1 new', '@count new');
$variables['forums'][$id]->new_url = url("forum/$forum->tid", NULL, 'new');
}
$variables['forums'][$id]->old_topics = $forum->num_topics - $variables['forums'][$id]->new_topics;
/*added line*/
$variables['forums'][$id]->new_posts= (_forum_comments_unread($forum->tid, $user->uid)) + ( _forum_topics_unread($forum->tid, $user->uid));
if ($variables['forums'][$id]->new_posts) {
$variables['forums'][$id]->new_text_posts = format_plural($variables['forums'][$id]->new_posts, '1 new', '@count new');
$variables['forums'][$id]->new_url_posts = url("forum/$forum->tid", NULL, 'new');
}
$variables['forums'][$id]->old_posts = $forum->num_posts - $variables['forums'][$id]->new_posts;
}
/*and of added line*/
// We overwrite this in the advforum preprocess, so might as well not do it here
//$variables['forums'][$id]->last_reply = theme('forum_submitted', $forum->last_post);
}
// Give meaning to $tid for themers. $tid actually stands for term id.
$variables['forum_id'] = $variables['tid'];
unset($variables['tid']);
}
?>
in avdf-forum-list.tpl.php, please add :
<?php print $forum->num_posts ?><?php if ($forum->new_posts): ?><br />
<a href="<?php print $forum->new_url_posts; ?>"><?php print $forum->new_text_posts; ?></a>
<?php endif;
?>
after
<td class="posts">:D
#5
Ok, I understand what you want, now. I can't use this as is because you are modifying the d6compat file but I will look at how to add this feature.
Thanks,
Michelle
#6
I can't get the above code to work sadly. It does put out some numbers, but not the number of new comments and forums that contain new comments since last visit do not get counted.
#7
A long time ago I submitted this code to g.d.o.: http://groups.drupal.org/node/7916
It was supposed to show icons for forums that contained new posts and/or new comments, but sadly it does not work anymore with the updated module.
I really really need this functionality - any thoughts of how to update my old code snippet to work with adv.forum?
edit: sorry if i should have created a new issue for this, i can if want me to :)
#8
re #7, there already is an issue: http://drupal.org/node/244329
Michelle
#9
I've tentitively committed #4 to the D6 branch. I'm concerned about the speed of the query. I'd appreciate if someone could take a look at it and see if it can be optomized. I'm not sure this feature is worth the speed decrease.
Michelle
#10
Ok, committed to both branches. It still is a performance problem for larger forums but I wrapped it in an advanced setting so it can be turned off if needed.
Michelle
#11
Automatically closed -- issue fixed for two weeks with no activity.