04-01-2012, 09:41 AM
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
Screenshots:
Threadlist - Showthread
[attachment=763] [attachment=764]
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
- Value: 1
- Edit our forumdisplay_thread_rating template:
HTML Code<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<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;"> </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']}&rating=1&my_post_key={$mybb->post_code}">1</a></li> <li><a class="two_stars" title="{$lang->two_stars}" href="./ratethread.php?tid={$thread['tid']}&rating=2&my_post_key={$mybb->post_code}">2</a></li> <li><a class="three_stars" title="{$lang->three_stars}" href="./ratethread.php?tid={$thread['tid']}&rating=3&my_post_key={$mybb->post_code}">3</a></li> <li><a class="four_stars" title="{$lang->four_stars}" href="./ratethread.php?tid={$thread['tid']}&rating=4&my_post_key={$mybb->post_code}">4</a></li> <li><a class="five_stars" title="{$lang->five_stars}" href="./ratethread.php?tid={$thread['tid']}&rating=5&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>
Screenshots:
Threadlist - Showthread
[attachment=763] [attachment=764]