Posted by Keyz on June 22, 2009 at 12:28am
| Project: | Blueprint |
| Version: | 6.x-1.6 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
I noticed that on comments that span multiple pages the comment # permalinks (in comment.tpl.php) do not work correctly (they work on the initial page, but subsequent pages do not receive the ?page=# part of the URL, and consequently do not work at all).
I've found an alternate code snippet in Advanced Forum module (thanks Michelle!) that fixes this. This function of course goes in template.php, and the line in comment.tpl.php would be replaced with simply <?php print $comment_link; ?>.
I have slightly adjusted the original snippet to remove its dependency on Advanced Forum. Feel free to adjust it further if I've missed anything (I'm not an expert yet).
function blueprint_preprocess_comment($vars) {
/**
* Create a permalink with comment # for each comment.
* From Advanced Forum module.
*/
if (!isset($post_number)) {
static $post_number = 0;
}
$post_per_page = _comment_get_display_setting('comments_per_page', $variables['node']);
$page_number = $_GET['page'];
if (!$page_number) {
$page_number = 0;
}
$post_number++;
$fragment = 'comment-' . $variables['comment']->cid;
$query = ($page_number) ? 'page=' . $page_number : NULL;
$linktext = '#' . (($page_number * $post_per_page) + $post_number);
$linkpath = 'node/' . $variables['node']->nid;
$variables['comment_link'] = l($linktext, $linkpath, array('query' => $query, 'fragment' => $fragment));;
}
Comments
#1
Upon closer investigation, I realized that not only was the pager not working but the comment count on each comment was getting reset on each page.
Attached is a patch that fixes both the count and the permalink to account for the pager.
#2
Committed [#281116]
#3
#4
Automatically closed -- issue fixed for 2 weeks with no activity.
#5
subscribing.
#6
@fehin: is this something you are still having a problem with? This is a closed issue and has been addressed in the 1.6 version of the module. If you are still having problems with it in the 1.6 version, you are welcome to reopen the issue but be sure to post information about what the problem is that you are having.