Download & Extend

nodevote won't work with paging.module

Project:Node Vote
Version:4.6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

I need multiple pages so I installed the paging.module. However, nodevote won't show voting on nodes that are multiple page displays. I looked at the code. The only thing that seems to affect this is

if (variable_get(NODEVOTE_TYPE . $node->type, '0'))

How should I modify the code so that node spliting over multiple pages can be voted on?

Thanks

Comments

#1

Priority:critical» normal

One option is to have a settings that would say "put vote on top" or "put vote on bottom".
If it is on the top, it would be visible in the first page.

Not sure if that would cover all cases or not.

Patches and ideas welcome.

Setting priority to normal.

#2

Version:4.6.x-1.x-dev» 4.7.x-1.x-dev

'One option is to have a settings that would say "put vote on top" or "put vote on bottom".
If it is on the top, it would be visible in the first page.'

It would be great to have an option to be able to put just the score, or stars, on top as well since that's what would catch the eye first.

#3

Version:4.7.x-1.x-dev» 4.6.x-1.x-dev

The problem here is that the paging_nodeapi is called with the $op='load' before the nodevote_nodeapi $op='view' is called. The paging_nodeapi $op='load' breaks up the body into pages and saves it into the $node->pages[] array. The paging_nodepai $op='view' replaces the $node->body with $node->pages[$from]. In effect, it bypasses the addition of the nodevote information saved in $node->body. I resolved it this way by adding to nodevote_nodeapi to detect $node->pages_count and modify $node->pages instead of $node->body.

function nodevote_nodeapi(&$node, $op, $teaser, $page) {
global $user;
switch($op) {
case 'load':
if (variable_get(NODEVOTE_TYPE . $node->type, '0')){
if (_nodevote_vote_is_visible($node)) {
$extra['nodevote']->vote_display = 1;
}
if (_nodevote_is_votable($node)) {
$extra['nodevote']->vote_do = 1;
}
}
return $extra;
case 'view':
if (variable_get(NODEVOTE_TYPE . $node->type, '0')) {
if ($node->nodevote->vote_display) {
$vote = theme('nodevote_display_vote',$node->nid);
if ($page)
{
if ($node->pages_count) {
$node->pages[($node->pages_count - 1)] .= $vote;
}
else {
$node->body .= $vote;
}
}
else
{
$node->teaser .= $vote;
}
}
}

if ($page) {
if ($node->nodevote->vote_do) {
$vote = theme('nodevote_do_vote',$node);
if ($node->pages_count) {
$node->pages[($node->pages_count - 1)] .= $vote;
}
else {
$node->body .= $vote;
}
}
}
break;
case 'delete':
$r = db_query('DELETE FROM {nodevote} WHERE nid = %d', $node->nid);
break;
}
}

#4

Are you sure this does not break the normal working of nodevote, when people do NOT have paging module enabled?

If so, then please make this in proper patch format and I will include it.

#5

I have made the code test for $node->pages_count which is used by the paging module. I have tested this with another drupal install without the paging module. It works fine.

btw what is the proper patching format?

#6

Here are the details http://drupal.org/patch

Please make sure that you do it against the most recent 4.7 or HEAD, so it is easy to review and gets in faster.

#7

I have made the patch against the version of 4.7 released on 8/31/2006. Since I am not using 4.7, I did not test it. The change is only to check for the $node->pages_count variable and to add the voting information to the $node->pages instead of the $node->body. Since when paging module is used, the display is from $node->pages instead of $node->body.

AttachmentSize
nodevote_paging.patch 1.24 KB

#8

this is the 4.6 patch.

AttachmentSize
nodevote_paging46.patch 1014 bytes
nobody click here