TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,966
  • Latest: safir45
Stats
  • Total Posts: 195,993
  • Total Topics: 21,324
  • Online today: 329
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 279
  • Total: 279

Real url to rate an article

Started by estecb, March 05, 2009, 03:40:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

estecb

What's up? I'm trying to change the rating system. Instead of the form by default, I want to make the rating options with ul and li code (I don't know how it's called).
Well, here's the thing, I need to know what is the real url to rate an article...

For example, if I rate an article with 5 points...

The form would submit something like:

http://www.myweb.com/index.php?action=tpmod;[article_id];[session_id];sa=rate_article#5

But obviously, it's not submitting that (I mean it's not the right code).

I've a html example that may give you a clue of what I'm trying to do:

<ul class="star-rating">
<li class="current-rating" style="width:[var.rate]%;"></li>
<li><a href="yourweb.com/rate.php?rate_id=[var.vid]&amp;rate=1" title="1 star out of 5" class="one-star">1</a></li>
<li><a href="yourweb.com/rate.php?rate_id=[var.vid]&amp;rate=2" title="2 stars out of 5" class="two-stars">2</a></li>
<li><a href="yourweb.com/rate.php?rate_id=[var.vid]&amp;rate=3" title="3 stars out of 5" class="three-stars">3</a></li>
<li><a href="yourweb.com/rate.php?rate_id=[var.vid]&amp;rate=4" title="4 stars out of 5" class="four-stars">4</a></li>
<li><a href="yourweb.com/rate.php?rate_id=[var.vid]&amp;rate=5" title="5 stars out of 5" class="five-stars">5</a></li>
</ul>

I just need the ''real'' submit url, so I can figure out the whole thing.

thank's in advanced

G6Cad


/index.php?action=tpmod;sa=rate is the direct link, and then it difffer from where you do the rating

And as you didnt provide us with any ifo exept your own wantings, i will ask you to read the posting guidelines and add the info we ask for.
Please read the Posting Guidelines.html

estecb

Yep, sorry.

Link to my site: http://www.akademia.com.ar
SMF version: SMF 1.1.8
TP version: TP v0.9.8
Theme name and version: Default
Mods installed: none
Related Error messages: none


there's no way to get the direct link? maybe making some modification in TPortal.template.php?

btw, thanks for ur reply

IchBin

The rating is not posted via $_GET. It is posted via $_POST. Which means you can't use a URL to post a rating. All the form is doing is post to this URL.
http://www.tinyportal.net/index.php?action=tpmod;sa=rate_article

The rest of the variables are post in the $_POST array.

estecb

#4
Ok, thanks IchBinâ„¢... one more question, would it be possible to change the $post to $get?
What I really want is remove the rate menu (or list) and make it with animated stars...

Thanks!

bloc

Why do you need to change the POST value to GET..? Using GET is very unsecure and fake voting will be very easy to do then.

If you want to just change the looks of it - have a look at TPortal.template.php, thats where the votes are shown, both the rating form and the results.

The voting form:
// can we rate it?
if(isset($context['TPortal']['show_single_page']) && isset($story['options']['ratingallow'])  && $context['user']['is_logged']){
if($story['can_rate']){
echo '
<hr />
<div class="smalltext" style="padding: 1ex;">', $txt['tp-ratearticle'] ,'
<form name="tp_article_rating" action="',$scripturl,'?action=tpmod;sa=rate_article" method="post">
<select size="1" name="tp_article_rating">';
for($u=$context['TPortal']['maxstars'] ; $u>0 ; $u--){
echo '
<option value="'.$u.'">'.$u.'</option>';
}
echo '
</select>
<input type="submit" name="tp_article_rating_submit" value="',$txt['tp_rate'],'">
<input name="tp_article_type" type="hidden" value="article_rating">
<input name="tp_article_id" type="hidden" value="'.$story['id'].'">
<input type="hidden" name="sc" value="', $context['session_id'], '" />
</form>
</div>';
}
else
echo '
<hr /><i>'.$txt['tp-haverated'].'</i>';
}


..and the showing of the votes:
if(isset($story['options']['rating']))
$opts[] = '<span class="smalltext">' . $txt['tp-ratingaverage'] . ' ' . ($context['TPortal']['showstars'] ? (str_repeat('<img src="'.$settings['images_url'].'/tpblue.gif" style="width: .7em; height: .7em; margin-right: 2px;" alt="" />', $story['rating_average'])) : $story['rating_average']) . ' (' . $story['rating_votes'] . ' ' . $txt['tp-ratingvotes'] . ') </span>';

estecb

Thanks! Bloc, I'll try that... mmmh another question, the vote results are always 1, 2, 3, 4, or 5... Is there a way to change that? I want to show 4.5 (if someone vote 5 and then other person vote 4), or 3.2 and so on.

thanks!

bloc

Not in the 0.9.8 version..I am working to add a general rating system in TP v1.0 beta 4 though, that all parts of TP can use. It will use weighted or bayesian rating and allow rates like 6.5 etc.

estecb

#8
good to know :)... in the midtime, how can I redirect members to the mainpage after voting?

I make some modification for vote from the mainpage (on my local host) but the problem is that I'm always redirected to the article page (mywebsite.com/page=90 , for example) after vote.

thanks for ur reply, it's much appreciated!

bloc

To redirect to mainpage open TPmodules.php and find:
// go back to the article
redirectexit('page='.$article);

change that to simply:
// go back to the mainpage
redirectexit();

This website is proudly hosted on Crocweb Cloud Website Hosting.