Introduction to Reviews > Invisionize.eu - IP.Board (IPB) News
Kanał Rss Kanał Rss
Kanał Atom Kanał Atom

Introduction to Reviews

wersja drukowalna wersja Microsoft Word wersja HTML

Reviews are almost identical to comments - they behave in the same way and all of the options available to comments are the same as for reviews.

Reviews differ in a few key ways:

  • When submitting a review, in addition to the text, members will have to provide a rating

    out of 5.

  • Other members can mark if they found the review helpful or unhelpful and reviews can

    be sorted by the most helpful.

  • Members can only submit one review per content item.

    You can follow the instructions for implementing comments to implement reviews with a few small differences:

    The Model

    Your model class for reviews need to extend IPSContentReview (which in turn extends IPSContentComment).

    There are a number of additional databaseColumnMap elements that are required:

Element

Description

rating

The rating (0-5) submitted with the review.

votes_total

The total number of helpful/unhelpful votes received.

votes_helpful

The number of votes_total that were voted as helpful.

votes_data

A JSON object containing details about who has voted helpful/unhelpful and what they voted

Changes to make to Content Item model

Rather than add a new property to your Content Item model called $commentClass, add a property called $reviewClass:

/**
* @brief Review Class */

     public static $reviewClass = 'IPSyourappYourClass';

And for $databaseColumMap:

Element name for Comments

Element name for Reviews

num_comments

num_reviews

last_comment

last_review

last_comment_by

last_review_by

75

Element name for Comments

Element name for Reviews

unapproved_comments

unapproved_reviews

You can optionally also add an additional element “rating” which will contain the current average rating for all reviews.

Additional properties and methods in IPSContentItem

Comments

Reviews

static $commentsPerPage

static $reviewsPerPage

commentPageCount()

reviewPageCount()

commentPagination()

reviewPagination()

comments( ... )

reviews( ... )

commentForm()

reviewForm()

lastCommentPageUrl()

lastReviewPageUrl()

canComment()

canReview()

moderateNewComments( ... )

moderateNewReviews( ... )

canViewHiddenComments( ... )

canViewHiddenReviews( ... )

averageReviewRating()

Returns an integer between 1 and 5 indicating the average rating for the item.

Displaying

Here is some recommended HMTL for displaying reviews:

<div data-controller='core.commentFeed' data-feedID='file-{$item-
>id}-reviews'>
     {{if $item->canReview()}}
          <h2 class='ipsType_sectionTitle'>{lang="write_a_review"}

</h2>

          <br>
     {{endif}}
     <div class="ipsClearfix">
          {{if $item->reviewPageCount() > 1}}
               <div class="ipsPos_left">
                    {$item->reviewPagination( array( 'tab',
'sort' ) )|raw}
<div class='ipsAreaBackground_light ipsPad'>
     {$item->reviewForm()|raw}

</div>

76

</div>
          {{endif}}
          <div class="ipsButtonBar ipsClearfix
ipsResponsive_showDesktop ipsPos_right">
               <ul class="ipsButtonRow ipsPos_left ipsClearfix">
                    <li data-action="tableFilter" data-filter="">
                         <a href="{$item->url()-
>setQueryString( array( 'tab' => 'reviews', 'page' => 1, 'sort' =>
'helpful' ) )}" class="{{if !isset( request.sort ) or request.sort
!= 'newest'}}ipsButtonRow_active{{endif}}" data-
action="filterClick">{lang="most_helpful"}</a>

</li>

                    <li data-action="tableFilter" data-
filter="members_filter_banned">
                         <a href="{$item->url()-
>setQueryString( array( 'tab' => 'reviews', 'page' => 1, 'sort' =>
'newest' ) )}" class="{{if isset( request.sort ) and request.sort
== 'newest'}}ipsButtonRow_active{{endif}}" data-
action="filterClick">{lang="newest"}</a>

</li> </ul>

          </div>
     </div>
     <br><br>
     <div data-role='commentFeed'>
          {{foreach $item->reviews() as $review}}
               {$review->html()|raw}
          {{endforeach}}
     </div>

</div> 

 

Example: 

 

czw, 01 wrzesień 2016