Skocz do zawartości
Zaloguj się, aby obserwować  
Invisionize.eu

[Dokumentacja IPS4] Introduction to Reviews

Polecane posty

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 \IPS\Content\Review (which in turn extends \IPS\Content\Comment).

    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 = 'IPS\yourapp\YourClass';

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 \IPS\Content\Item

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: 

 

Wyświetl pełny artykuł

Udostępnij ten post


Link to postu
Udostępnij na innych stronach

Bądź aktywny! Zaloguj się lub utwórz konto

Tylko zarejestrowani użytkownicy mogą komentować zawartość tej strony

Zaloguj się, aby obserwować  

  • Kto przegląda   0 użytkowników

    Brak zalogowanych użytkowników przeglądających tę stronę.

×

Ważne informacje

Kontynuując przeglądanie strony, wyrażasz zgodę na używanie przez nas plików cookies.