1
3lr0n
news 1.64 rating system hack
  • 2009/11/24 18:25

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


Hello,

Iam trying to modify the rating system of news 1.4 module to set in index.php and article.php (news listing and news detail pages) a +1 point vote clicking and image (thumbs up or somethink like that), the problem is that this code on index.html (template file) redirects me to voting page (ratenews.php) instead of updating the votes.

<form action="<{$xoops_url}>/modules/news/ratenews.php" method="post">
               <
input type="hidden" value="<{$story.id}>" name="storyid"/>
                <
input type="hidden" value="1" name="rating"/>
                <
input type="image" src="<{$xoops_url}>/modules/news/images/thumbs_up.gif">
                </
form>


The only change is that the form is submitted from another page (index.php instead of ratenews.php) and the select is replace with a hidden field with the vote value).

Any idea?

PS: I have allready modifed the class to avoid the average calculation and only sum the votes.

2
Dylian
Re: news 1.64 rating system hack
  • 2009/11/24 19:36

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


Add:
<input type="hidden" name="submit" value="1" />

To your code and it should work .

But with your current code the rating of the article will get lower and lower an lower instead of higher...
Maybe for thumbs up this is better:
<input type="hidden" value="6" name="rating" />

And for thumbs down:
<input type="hidden" value="4" name="rating" />


Greets Dylian.

3
3lr0n
Re: news 1.64 rating system hack
  • 2009/11/24 20:04

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


Quote:
But with your current code the rating of the article will get lower and lower an lower instead of higher...


function news_updaterating($storyid)
{
    global 
$xoopsDB;
    
$query 'SELECT rating FROM '.$xoopsDB->prefix('stories_votedata').' WHERE storyid = '.$storyid;
    
$voteresult $xoopsDB->query($query);
    
$votesDB $xoopsDB->getRowsNum($voteresult);
    
$totalrating 0;
    while(list(
$rating)=$xoopsDB->fetchRow($voteresult)){
        
$totalrating += $rating;
    }
     
$finalrating $totalrating//$votesDB;
    
$finalrating number_format($finalrating4);
    
$sql sprintf("UPDATE %s SET rating = %u, votes = %u WHERE storyid = %u"$xoopsDB->prefix('stories'), $finalrating$votesDB$storyid);
    
$xoopsDB->queryF($sql);
}


Just comment in the $finalrating line where it makes the division and "voila", you have a increasing rating , if all the points are +1 , the votes and the points are same.

<input type="hidden" name="submit" value="1" />


works fine.. thanks

Login

Who's Online

72 user(s) are online (41 user(s) are browsing Support Forums)


Members: 0


Guests: 72


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Aug 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits