Jump straight to last post...

118 posts / 0 new
Last post
Felix Frost's picture
Felix Frost
Offline
Joined: 30-12-05
Mar 23 2007 12:15
Mike Harman wrote:
The isse with forums/tracker is probably because it's a custom view made with the views module.

Might as well fix the views module too then:

In the file modules/views/modules/views_comments.inc change the function views_handler_comments_with_new to the following


function views_handler_comments_with_new($fieldinfo, $fielddata, $value, $data) {
$comments = intval($value);
if ($comments && $new = comment_num_new($data->nid)) {
$comments_per_page = variable_get('comment_default_per_page', 0);
$pagenum = NULL;
$pageno = (intval($value) - comment_num_new($data->nid)) / $comments_per_page;
if ($pageno > 1) $pagenum = "page=" . intval($pageno);
$comments .= '<br />';
$comments .= l(t('@num new', array('@num' => $new)), "node/$data->nid", NULL, $pagenum, 'new');
}
return $comments;
}

Jacques Roux's picture
Jacques Roux
Offline
Joined: 17-07-06
Mar 23 2007 12:18

Thanks for all this btw FF....

How come you don't use template.php though? It makes life much easier.

Mike Harman
Offline
Joined: 7-02-06
Mar 23 2007 13:42

FF, feel cheeky asking, but is there a way to change this from linking to #new to linking to the actual first unread comment cid?

We're going to fix the #new anchors in the theme, but I thought the cid itself would be another option maybe. No worries, at all, if not.

Lazy Riser's picture
Lazy Riser
Offline
Joined: 6-05-05
Mar 23 2007 14:28
Quote:
How come you don't use template.php though? It makes life much easier.

Not in general though. I mean, it makes some people's lives easier. What criteria are you using to measure easiness?

Lazy Riser's picture
Lazy Riser
Offline
Joined: 6-05-05
Mar 23 2007 14:30

Please allow me to withdraw that last post. Developer habit took over.

jef costello's picture
jef costello
Offline
Joined: 9-02-06
Mar 23 2007 14:33
rkn wrote:
Interesting how page 5 on the pager shows as page 4 in the address bar. Doesnt matter tho.

It's cause the first page doesn't have a number cause it needs the clean URL.

I just realised that you know that already, still, at least I knew something.

Felix Frost's picture
Felix Frost
Offline
Joined: 30-12-05
Mar 23 2007 18:07
Mike Harman wrote:
FF, feel cheeky asking, but is there a way to change this from linking to #new to linking to the actual first unread comment cid?

We're going to fix the #new anchors in the theme, but I thought the cid itself would be another option maybe. No worries, at all, if not.

I suppose it's possible, but I don´t see a great advantage in it if it takes you to the same post anyway. I think it will be easier to get the anchors to work. I looked a bit at that today, and it's quite odd. I got it to work by stopping the flatforum.css stylesheet from loading, but when I looked through the stylesheet, I didn't see anything that looked like a problem.

rkn wrote:
Thanks for all this btw FF....

How come you don't use template.php though? It makes life much easier.

I wouldn't know. I'm not using drupal in any of the websites I'm working on, so I'm not too familiar with it.

Jacques Roux's picture
Jacques Roux
Offline
Joined: 17-07-06
Mar 23 2007 18:17

Ah ok.

I thought the problem was in the changes flatforum makes to forum.tpl.php not in the css file.

Felix Frost's picture
Felix Frost
Offline
Joined: 30-12-05
Mar 25 2007 13:57

The problem is with the "float" styles. The easiest way to fix this is to give the "new" anchor the same style as the comment boxes, and it will then float together with them.

I did this in the comment.module file, but I assume you will want to do it in one of the template files that goes with your theme:

in function theme_comment_view

replace

$output = '';
$comment->new = node_mark($comment->nid, $comment->timestamp);
if ($first_new && $comment->new != MARK_READ) {
// Assign the anchor only for the first new comment. This avoids duplicate
// id attributes on a page.
$first_new = FALSE;
$output .= "<a id=\"new\"></a>\n";
}

with

$output = '<div class="forum-comment">';
$comment->new = node_mark($comment->nid, $comment->timestamp);
if ($first_new && $comment->new != MARK_READ) {
// Assign the anchor only for the first new comment. This avoids duplicate
// id attributes on a page.
$first_new = FALSE;
$output .= "<a id=\"new\"></a></div>\n";
}

Also, you need to get rid of the extra "new" anchors made by the flatforum node-forum.tmp.php file. You already have an anchor where it should be, and multiple anchors with the same name confuse some browsers. My copy of Opera now takes me to the last post on the page instead of the first unread.

Jacques Roux's picture
Jacques Roux
Offline
Joined: 17-07-06
Mar 25 2007 17:41

Thanks FF, will give it a go later.

I guess in an idea world we would have 'new' links going to the first unread post and maybe a jump to last post icon, next to the last post column which takes you to the very last post. But that might be surplus.

Jacques Roux's picture
Jacques Roux
Offline
Joined: 17-07-06
Mar 26 2007 17:40

hmm done it. Seems to be working.

Anyone else getting the sidebar not coming up in the right place anymore?

Jacques Roux's picture
Jacques Roux
Offline
Joined: 17-07-06
Mar 26 2007 17:47

Ok, so i looked for the line to take out in node-forum.tpl.php (flatforum file)
new ? ' comment-new forum-comment-new' : ''; ?>">
I took out:
print $comment->new ? ' comment-new forum-comment-new' : '';
And it stopped it working, so i put it back in and now click on new links takes you to first unread post. Which is great. So i guess how it prints new links is fine? But sidebar seems a bit messed up now. I guess thats to do with float, - but cant figure out where to fix

Mike Harman
Offline
Joined: 7-02-06
Mar 26 2007 18:38

sidebar messed up for me now. New links working great though11!!!!!!!!!1!!!!!!!!!

Did a float get taken out somewhere?

Jacques Roux's picture
Jacques Roux
Offline
Joined: 17-07-06
Mar 26 2007 18:41

the only change was aapplying

to new. I messed with forum-comment in forum.css and i couldnt fix sidebar

Mike Harman
Offline
Joined: 7-02-06
Mar 26 2007 18:45

Just ran validation - started new thread since we should check most common pages for validation. Pretty sure you left that div unclosed.

Felix Frost's picture
Felix Frost
Offline
Joined: 30-12-05
Mar 26 2007 18:53
rkn wrote:
Ok, so i looked for the line to take out in node-forum.tpl.php (flatforum file)
new ? ' comment-new forum-comment-new' : ''; ?>">
I took out:
print $comment->new ? ' comment-new forum-comment-new' : '';

Those lines are style tags. What you need to take out is the line:
<a id="new"></a>

I can see the problem with the rightbar floating to the left. The code I posted earlier needs a slight correction. Try this instead:

$output = '';
$comment->new = node_mark($comment->nid, $comment->timestamp);
if ($first_new && $comment->new != MARK_READ) {
// Assign the anchor only for the first new comment. This avoids duplicate
// id attributes on a page.
$output = '<div class="forum-comment">';
$first_new = FALSE;
$output .= "<a id=\"new\"></a></div>\n";
}

Jacques Roux's picture
Jacques Roux
Offline
Joined: 17-07-06
Mar 26 2007 19:00

Ok great.... that's excellent. Thanks a lot! Wish i actually knew how to do this stuff instead of fumbling in the dark sad

I took out that line from -

	<?php if ($comment->new) : ?>
      <a id="new"></a>
      <?php print $new ?>
    <?php endif ?>
Steven.'s picture
Steven.
Offline
Joined: 27-06-06
Mar 27 2007 09:44

shit this is working perfectly now, well done all!

quoted text is now showing up in funny coloured boxes though...

Refused's picture
Refused
Offline
Joined: 28-09-04
Mar 27 2007 10:03

It works!!

I can die happy now.

Felix Frost's picture
Felix Frost
Offline
Joined: 30-12-05
Apr 3 2007 16:32
rkn wrote:
I guess in an idea world we would have 'new' links going to the first unread post and maybe a jump to last post icon, next to the last post column which takes you to the very last post. But that might be surplus.

If you would like a 'jump to the last post' function also, it's fairly easy to do. Or what about links to all the pages of comments like I think you used to have before you switched to Drupal? (That would be even easier to do.) It might also be nice to put the name of the last poster on the tracker page, like it is on the forum pages.

Just tell me what you would like, and I can write the code for you.

And how about fixing the 'new' links in the views module, so I can start using my forums/tracker bookmark again? I found that more useful than the regular tracker page.

Jacques Roux's picture
Jacques Roux
Offline
Joined: 17-07-06
Apr 3 2007 16:56
Quote:
Just tell me what you would like, and I can write the code for you.

Thats great! Thanks so much.... when you are in London we will owe you quite a few drinks wink

Quote:
If you would like a 'jump to the last post' function also, it's fairly easy to do.

Yeah - i think it would be cool to have in the 'last post' column a little jump to last post icon - just like phpBB really.

Quote:
Or what about links to all the pages of comments like I think you used to have before you switched to Drupal?

Under the thread name? Yes that would also be excellent.

Quote:
It might also be nice to put the name of the last poster on the tracker page

Yeah in the last updated column could have 'by...." after the time. It would be cool to have the jump to last post icon there as well.

New links/views module/ forums/tracker - i think catch knows whats going on here, because right now http://libcom.org/forums/tracker is showing not just forum entries but all entries. Likewise with http://libcom.org/forums/tracker/username - it doesnt seem to be working. Will let catch answer on this.

Tojiah's picture
Tojiah
Offline
Joined: 2-10-06
Apr 3 2007 16:57

A wee glitch with the "new" link: when the new messages are all in a new page, the "new" link jumps to the one before it. For example, if there are 31 messages, 1 new, then the link goes to the first page (page 0) instead of the second one (page 1).

Any idea why that is?

Also, reading over the last few comments, the PHP code sort of floats above the text between lines, partially obscuring them.

Felix Frost's picture
Felix Frost
Offline
Joined: 30-12-05
Apr 5 2007 09:03
tojiah wrote:
A wee glitch with the "new" link: when the new messages are all in a new page, the "new" link jumps to the one before it. For example, if there are 31 messages, 1 new, then the link goes to the first page (page 0) instead of the second one (page 1).

Any idea why that is?

I think that only happens when the new comments are all on the second page, but not on page 3, 4, etc.
But, yeah, that was a small oversight of me. I'll fix that too.

I'll sit down sometime this weekend and write some code for you. If you send me a copy of your theme files, I can try to make the changes there, instead of in the forum.module file.

Do you have a backup site that we can test things out on, btw, instead of testing everything on the live site?

Steven.'s picture
Steven.
Offline
Joined: 27-06-06
Apr 5 2007 09:38
Felix Frost wrote:
Do you have a backup site that we can test things out on, btw, instead of testing everything on the live site?

Pffft. That's for sissies.

Joseph Kay's picture
Joseph Kay
Offline
Joined: 14-03-06
Apr 5 2007 09:42

but we do though, don't we? [/sissy]

Mike Harman
Offline
Joined: 7-02-06
Apr 5 2007 09:45

Felix, I've done tracker, sorry that took so long. Will get round to fixing the forums tracker to it works again asap.

Yes a copy of the theme is no problem - can e-mail you as a gzip?

Yes we have a test site but it's a bit out of date now, and we're not very organised about using it.

Couple of things, we don't allow user settings of comments (because IMO it's broken and shouldn't be in drupal core anyway) - but as you're giving us these I'm rolling them into patches for drupal.org with the hope it'll get fixed permanently in drupal 6.x http://drupal.org/node/6162

haven't done it on here yet, but to take that into account have changed:
variable_get('comment_default_per_page', 0);

with

_comment_get_display_setting('comments_per_page');

on someone's advice

works the same afaik.

I'll try to do the views patch in a bit as well, if we could get comment new links fixed in views.module that'd be a major step.

Felix Frost's picture
Felix Frost
Offline
Joined: 30-12-05
Apr 5 2007 21:35
Mike Harman wrote:
Yes a copy of the theme is no problem - can e-mail you as a gzip?

Sure, that's good.

Quote:
Couple of things, we don't allow user settings of comments (because IMO it's broken and shouldn't be in drupal core anyway) - but as you're giving us these I'm rolling them into patches for drupal.org with the hope it'll get fixed permanently in drupal 6.x http://drupal.org/node/6162

I can do a version that works with user settings also. The biggest problem is to make it work with threaded comments without using too many database queries. I looked at the discussion on the drupal forum, and someone had written a patch for this a long time ago, but it was apparently rejected because it used too much code and too many queries.

Mike Harman
Offline
Joined: 7-02-06
Apr 5 2007 22:49

to be honest, I think drupal should just drop user settings for comments (we tried it for a day, it was really, really ugly), and ideally drop threading as well. Then it'd be easy!

Mike Harman
Offline
Joined: 7-02-06
Apr 11 2007 10:50

someone came up with another patch - don't think it fixes the new links though:

Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.537
diff -u -r1.537 comment.module
--- modules/comment/comment.module	9 Apr 2007 13:41:10 -0000	1.537
+++ modules/comment/comment.module	11 Apr 2007 10:12:18 -0000
@@ -332,7 +332,7 @@
 function theme_comment_block() {
   $items = array();
   foreach (comment_get_recent() as $comment) {
-    $items[] = l($comment->subject, 'node/'. $comment->nid, array('fragment' => 'comment-'. $comment->cid)) .'<br />'. t('@time ago', array('@time' => format_interval(time() - $comment->timestamp)));
+    $items[] = l($comment->subject, "node/$comment->nid/$comment->cid") .'<br />'. t('@time ago', array('@time' => format_interval(time() - $comment->timestamp)));
   }
   if ($items) {
     return theme('item_list', $items);
Felix Frost's picture
Felix Frost
Offline
Joined: 30-12-05
Apr 11 2007 17:01

I don't think that does anything in fact.
Just cleans up the code a bit on that one line.