MyBB Community Forums

Full Version: Implementing new way to rate a thread
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Excuse me all,

I am new to this community. However, I have been with MyBB for about 2 years. And I really fall in love with it :)

I am currently establishing my newly created forum site. My concern right now is just modifying the mobile theme (using MyBB GoMobile as base), therefore I want to make my site very friendly even for old phones.

Hence, I decided to change the method of rating a thread, for convenience. ( My phone is an old Android, the default rating thread, the stars couldnt appear, so I cannot rate the thread, even just to see how much the rating) 

Therefore, gladly I found an alternative to it. I changed the method to be using "select option" in HTML. Yes, finally using this, it functions well in my phone (it appaers and clickable). Unfortunately, it cannot work as it should be. For example, If i want to rate a thread, i choose a number, it doesn't response correctly, but an error message appears "Authorization code mismatch. Are you accessing this function correctly? Please go back and try again."

I am really stuck with this, still not knowing how to solve. With these, I humbly asks for help to the people here about this :)

My site URL:  www.noblun.com

Here is the codes I used there:
<select name="rateThread" onchange="getRating(this)">
  <option value="0" selected="">Rate it!</option> 
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
</select>
<script>
		function getRating(sel) {
    var rate = sel.value; 
			if (rate) { // require a URL
              window.location = "./ratethread.php?tid=1&amp;rating='rate'&amp;my_post_key=52116e4d0a8ad82f89f1ab895c6a02e1" // redirect
          }
}
</script>   


Thank you all for the attention :))
{$mybb->post_code} should be used instead of the actual post key number
window.location = "./ratethread.php?tid={$thread['tid']}&amp;rating='rate'&amp;my_post_key={$mybb->post_code}" // redirect
(2016-04-28, 08:15 AM).m. Wrote: [ -> ]{$mybb->post_code} should be used instead of the actual post key number
window.location = "./ratethread.php?tid={$thread['tid']}&amp;rating='rate'&amp;my_post_key={$mybb->post_code}" // redirect

thank you very much sir!

However, i did a mistake..I have changed the code as you said, now my codes became these:
<select name="rateThread" onchange="getRating(this)">
  <option value="0" selected>Rate it!</option> 
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
</select>
	<script>
		function getRating(sel) {
    var rate = sel.value; 
			if (rate) { // require a URL
              window.location = "./ratethread.php?tid={$thread['tid']}&amp;rating='rate'&amp;my_post_key={$mybb->post_code}" // redirect
          }
}
   
</script>

Unfortunately, it still doesnt response properly... Sad
Maybe something wrong with the "window.location" ?
^ can you check if this method works for you ..
(2016-04-28, 09:51 AM).m. Wrote: [ -> ]^ can you check if this method works for you ..

it works wonderfully sir!

Thank you very much!