Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Author Rating
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #1
Author Rating
Reuquirement: XThreads

This is a simple example for adding an author rating for our XThreads applications. So we can use the default MyBB rating as user's rating.
Maybe we can use it for our review forum or other type of forums.

In this example, we will apply it to general forum.

Create a custom thread fields:
AdminCP -> Configuration -> Custom Thread Fields
  • Title: Author Rating
  • Key: author_rating
  • Applicable Forums: 'select in which forum(s) we want to apply it'
  • Input Field Type: Option Buttons
  • Values List:

    Code:
    1
    2
    3
    4
    5

    Because we'll use the MyBB thread rating as user's rating, so we need to assign the same range.

  • Editable by / Required Field?: Everyone (required)
  • Display Format:

    HTML Code
    <div class="clear float_left" style="white-space: nowrap"><strong class="float_left">Author Rating:</strong><ul class="star_rating" style="margin-left: 110px"><li style="width: {VALUE}%" class="current_rating"></li></ul></div>

  • Underlying Data Type: Integer (unsigned)
  • Formatting Map List:
    • Value: 1
      Displayed Output: 20
    • Value: 2
      Displayed Output: 40
    • Value: 3
      Displayed Output: 60
    • Value: 4
      Displayed Output: 80
    • Value: 5
      Displayed Output: 100

    Code:
    1{|}20
    2{|}40
    3{|}60
    4{|}80
    5{|}100

  • Edit our forumdisplay_thread_rating template:

    HTML Code
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <td align="center" class="{$bgcolor}{$thread_type_class}" id="rating_table_{$thread['tid']}">
    	<strong class="float_left">User Rating:</strong>
    	<ul class="star_rating{$not_rated}" id="rating_thread_{$thread['tid']}" style="margin-left: 110px">
    		<li style="width: {$thread['width']}%" class="current_rating" id="current_rating_{$thread['tid']}">{$ratingvotesav}</li>
    	</ul>
    	<script type="text/javascript">
    	<!--
    		Rating.build_forumdisplay({$thread['tid']}, { width: '{$thread['width']}', extra_class: '{$not_rated}', current_average: '{$ratingvotesav}' });
    	// -->
    	</script>
    	{$GLOBALS['threadfields']['author_rating']}
    </td>

  • Edit our showthread_ratethread template:

    HTML Code
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    <div style="margin-top: 6px; padding-right: 10px;" class="float_right">
    	<script type="text/javascript" src="jscripts/rating.js?ver=1400"></script>
    	<div id="success_rating_{$thread['tid']}" style="float: left; padding-top: 2px; padding-right: 10px;">&nbsp;</div>
    	<strong style="float: left; padding-right: 10px;">{$lang->thread_rating}</strong>
    	<div class="inline_rating">
    		<ul class="star_rating{$not_rated}" id="rating_thread_{$thread['tid']}">
    			<li style="width: {$thread['width']}%" class="current_rating" id="current_rating_{$thread['tid']}">{$ratingvotesav}</li>
    			<li><a class="one_star" title="{$lang->one_star}" href="./ratethread.php?tid={$thread['tid']}&amp;rating=1&amp;my_post_key={$mybb->post_code}">1</a></li>
    			<li><a class="two_stars" title="{$lang->two_stars}" href="./ratethread.php?tid={$thread['tid']}&amp;rating=2&amp;my_post_key={$mybb->post_code}">2</a></li>
    			<li><a class="three_stars" title="{$lang->three_stars}" href="./ratethread.php?tid={$thread['tid']}&amp;rating=3&amp;my_post_key={$mybb->post_code}">3</a></li>
    			<li><a class="four_stars" title="{$lang->four_stars}" href="./ratethread.php?tid={$thread['tid']}&amp;rating=4&amp;my_post_key={$mybb->post_code}">4</a></li>
    			<li><a class="five_stars" title="{$lang->five_stars}" href="./ratethread.php?tid={$thread['tid']}&amp;rating=5&amp;my_post_key={$mybb->post_code}">5</a></li>
    		</ul>
    	</div>
    </div>
    <div style="margin-top: 6px; padding-right: 10px;" class="float_right">{$GLOBALS['threadfields']['author_rating']}</div>

Modify it as our needs.

Screenshots:
Threadlist - Showthread
       

04-01-2012 09:41 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
Author Rating - RateU - 04-01-2012 09:41 AM
RE: Author Rating - RateU - 04-11-2012, 05:22 AM
RE: Author Rating - Sama34 - 04-22-2012, 12:57 PM
RE: Author Rating - RateU - 04-24-2012, 04:47 AM

 Standard Tools
Forum Jump: