Posted by Democron on March 29, 2008 at 5:08pm
Jump to:
| Project: | Advanced Forum |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Michelle |
| Status: | closed (won't fix) |
Issue Summary
How can I put pagination on top of the forum topic, not only on the bottom of the page
Comments
#1
Changing settings a bit because this is on my to do list.
Michelle
#2
I did a workaround for this in D5 + advanced forum alpha12 by hacking the node.module:
my new node_show function looks like this. all changes are between #mod start and #mod end
function node_show($node, $cid) {
#mod start
//pager on very top
$comments_per_page = _comment_get_display_setting('comments_per_page');
$out = comment_render($node, $cid);#needed
$output = theme('pager', NULL, $comments_per_page, 0) ;
$output .= node_view($node, FALSE, TRUE);
# orig: $output = node_view($node, FALSE, TRUE);
#mod end
if (function_exists('comment_render') && $node->comment) {
$output .= comment_render($node, $cid);
}
// Update the history table, stating that this user viewed this node.
node_tag_new($node->nid);
return $output;
}
there may be other ways to do this, too. I found some other topics on this, too.
#3
Subscribed
#4
Thanks, but hacking core is not an option.
Michelle
#5
Yeah, I have the same request. In the mean time, I edited the comment.module (bad)
at around line 1040
if ($num_rows && ($comment_controls == COMMENT_CONTROLS_ABOVE || $comment_controls == COMMENT_CONTROLS_ABOVE_BELOW)) {$output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
}
++ $output .= theme('pager', NULL, $comments_per_page, 0);
$output .= $comments;
$output .= theme('pager', NULL, $comments_per_page, 0);
#6
@batbug2 - Again, hacking core is not an option.
@all - There has to be some way of doing this without hacking core or it's not going to get done. I can't control what people do on their own sites but I will not add something to this module that requires hacking core nor will I advise others to do it. Hacking core is a bad practice that will lead to headaches.
If someone can come up with a non hacking core fix for this, great. Otherwise it will have to wait until I can figure out how to do it.
Thanks,
Michelle
#7
Just got a clue from IRC. I don't have the time to work on this issue right now but recording it here so it doesn't get lost.
[14:49] Michelle: Add a advanced_forum_preprocess_node() function, $vars['pager'] = theme('pager', ...); in there, and your users can probably output $pager anywhere in their node template. Alternatively, the same goes for preprocess_page().
Michelle
#8
itresting, gotta look into it
#9
Subscribed
#10
Here is my solution.
Put this code into advanced_forum.module (function name: advanced_forum_preprocess_node)
<?php$mixedObj = false;
$mixedObj->type = $variables["type"];
$mixedObj->comments_per_page = _comment_get_display_setting('comments_per_page',$mixedObj);
pager_query("SELECT count(*) FROM {comments} WHERE nid=".$variables["nid"], $mixedObj->comments_per_page);
?>
add this into your advf-comment-wrapper.tpl.php (before print $content);
<?phpif (isset($_GET['page']) && $_GET['page'] > 0) {
$comments_per_page = _comment_get_display_setting('comments_per_page',$node);
print theme('pager', NULL, $comments_per_page, 0);
}
?>
add this into your advf-forum-post.tpl.php (right after if ($top_post) { )
<?php$comments_per_page = _comment_get_display_setting('comments_per_page',$node);
print theme('pager', NULL, $comments_per_page, 0);
?>
This is my solution.
The SQL string used for pager_query is just a simple one and can maybe be even more simpler. I just couldn't imagine of a more simpler one which can work with LIMIT #,#.
This should not be seen as a final soultion. But it works and maybe someone can find a better way to implement this completly into advf.
This has been developed with alpha13 D6. Tests with alpha15 D6 didn't work, because advf-comment-wrapper.tpl.php wasn't called.
#11
Thanks for your work here. I'm going to hold it over for version 2 but it will be one of the first things that I look at.
Michelle
#12
Should note here that the bug with comment wrapper has now been fixed so this should work with the latest dev.
Michelle
#13
works here. D6 & alpha16 advf
#14
Is it ok to add this code (lassep's #10 comment) to the latest version of advf for my d5?
#15
All I did was put this in my code and it worked great. I'm a php noob though and this seemed too easy so I thought I'd check here.
<?php
print theme('pager')
?>
Also when i pasted it into the page.tpl above the content it pushes down everything. I want it in line with my "post new reply" etc at the top. Do I need to create a new .php file to edit forums?
#16
#17
Hi, I am trying to implement LasseP's fix noted in comment #10, but I have problem with advf-comment-wrapper.tpl.php part. It seems to me (I did some tests with print) that code in advf-comment-wrapper.tpl.php is not processed at all. I use default garland theme so I did not copy the *.tpl.php to theme directroy but I am changing it advanced_forum/styles/naked directory (others tpl.php changed in this directory works fine). Could you pls. help me if you see any hint.
#18
There's a bug in Garland that keeps the preprocess from running. You need to delete the phptemplate_comment_wrapper() (off the top of my head... might not be the right function name)
Michelle
#19
Thanks Michelle for the info. It is realy problem of Garland. I did not want to change core so I just little bit modified the LasseP's fix noted in comment #10. Here it is for someone who would like to use it in Garland. (It is more less copy of LasseP's fix, but I put it here whole not just modified parts to avoid confusion)
in file advanced_forum.module add at the end of function advanced_forum_preprocess_node() following
<?php$mixedObj = false;
$mixedObj->type = $variables["type"];
$mixedObj->comments_per_page = _comment_get_display_setting('comments_per_page',$mixedObj);
pager_query("SELECT count(*) FROM {comments} WHERE nid=".$variables["nid"], $mixedObj->comments_per_page);
?>
in file advanced_forum.module add at the end of function advanced_forum_preprocess_comment()
<?phpif (($post_number % $post_per_page) == 1) {
$variables['first_comment_on_page'] = TRUE;
}
else {
$variables['first_comment_on_page'] = FALSE;
}
?>
at the begining of file advf-forum-post.tpl.php add following:
<?phpif ($first_comment_on_page) {
$comments_per_page = _comment_get_display_setting('comments_per_page',$node);
print theme('pager', NULL, $comments_per_page, 0);
}
?>
#20
thanks lebloch, I just tired it and I see no effect, still no pagination at th etop of the forums, but I see the original at the bottom. Any idea what I might be missing?
#21
Hi AppleBag, Just one hint - this code shows pager on first page just bellow the first forum post (i.e. just above first comment of this forum post). So do not expect it at the top of the page. If it still not there, I have no idea what it can cause. It would require some reserch. For example if you add following code:
print "JUST TESTING";
at the begining of file advf-forum-post.tpl.php
Can you see the text "JUST TESTING" above each comment?
#22
Ahh ok, I win the "Duh" award for the day. lol
There it is, I was looking a the very top of the threads. Works great, thanks!
#23
Another perspective...
Though if we know the # of replies we could create a fake pager.
You just have to set the right values in $pager_total and er, whatever else it is.
Just wanted to get it recorded for now.
Michelle
#24
Here's what I did to get pagination on top of topics - I put it in advanced_forum_topic_header
Add this code to advanced_forum_preprocess_advanced_forum_topic_header(&$variables)
<?php
// Set up a pager
$node = $variables['node'];
$comments_per_page = _comment_get_display_setting('comments_per_page', $node);
$query = 'SELECT COUNT(*) FROM {comments} c WHERE c.nid = ' . $node->nid;
$result = pager_query($query, $comments_per_page, 0, NULL);
$variables['pager'] = theme('pager', NULL, $comments_per_page, 0);
?>
Then I just used
print $pagerat the very start of the advanced_forum_topic_header.tpl.php file#25
subscribe
#26
Postponing for 3.x / D7.
Michelle
#27
Just would like to add that advanced_forum_preprocess_advanced_forum_topic_header(&$variables) in #24 is located in file modules/contrib/advanced_forum/includes/theme.inc for Advanced Forum 6.x-2.x
#28
#24 works great
#29
Sandino #27, that path (modules\contrib\advanced_forum\includes\) doesn't exist anywhere I can find. Can you elaborate?
Thanks
#30
I used LasseP's code successfully, but, it only applies to forum topics, and not to comments on all content types (I'm using the AF feature of using AF styles on all comments.) So it doesn't look like AF is really treating all comments the same as comments on forum topics.
Also, on LasseP's code, with comments not on the first page, the top pager is getting placed to the right of the top comment instead of above it, causing the first comment on the page to be squished to the left.
Any ideas?
#31
@Steel Rat
Your location my vary, because I split my 'modules' directory into 'contrib' and 'custom' subdirectories. Thus your theme.inc may be located in 'sites/all/modules/advanced_forum/includes' directory.
#32
Nope. There's no 'includes' folder under the advanced_forum installation. And no 'theme.inc' anywhere in there.
#33
@Steel Rat: Then your install is messed up and I suggest you get a new copy.
Michelle
#34
There really isn't any good way of doing this in D6. #24 works (in theory; I haven't tried it) but requires an extra query. This will be easy enough to do once we move to entities for posts in 7.x-3.x so I plan on doing it there. However, I'm not going to keep this issue because it's getting long and none of it will be relevant to this in D7.
Michelle