Плагин отзывы в теме Euroshop

В настройках плагина используйте следующий шаблон вывода:

{if !waRequest::isXMLHttpRequest() && waRequest::method() != 'post'}{literal}
<style type="text/css">
    .reviews .review ul.menu-v li a { display: inline; padding: 0;}
    .reviews .review ul.reviews-branch li .reviews-branch li {border-bottom: 0}
    .reviews .review img.userpic { margin-right: 5px}
    .reviews .images {
        clear: left;
    }
    .reviews .images .image {
        vertical-align: middle;
        text-align: center;
        display: inline-block;
        width: 200px;
    }
    .reviews .images .image img {
        max-width: 100%;
        max-height: 250px;
    }
      table.reviews-stats {
        margin-bottom: 20px;
          width: auto;
        border: none;
      }
    table.reviews-stats td {
        border: none;
        padding: 3px 10px;
    }
    table.reviews-stats td div.bar {
        width: 200px;
        height: 13px;
        background: #eee;
    }
    table.reviews-stats td div.bar div {
        height: 13px;
        background: #f7c854;
    }
    .reviews .total-rating {
        margin: 0 10px;
        font-size: 120%;
    }
      .reviews-stats-title {
        margin-bottom: 20px;
      }
      .reviews .e-reviews__detail-open {
        vertical-align: top;
      }
</style>
{/literal}{/if}
<div class="reviews">
    {if !empty($reviews_settings.stats)}
        {$ratings = shopReviewsPlugin::getRatings()}
        {if $ratings.count}
            <div class="reviews-stats-title">
                Средняя оценка:
                <b class="total-rating">{str_replace(',', '.', round($ratings.rating, 1))}</b>
                {$wa->shop->ratingHtml($ratings.rating, 16)}
              
                  <a class="e-reviews__detail-open" onclick="$('.reviews-stats').toggle()"><i class="far fa-caret-square-down"></i></a>
            </div>
              <table class="reviews-stats" style="display: none">
                {foreach  $ratings.ratings as $rating => $count}
                <tr>
                    <td class="min-width hint">{$count}</td>
                    <td>
                        <div class="bar">
                            <div style="width:{str_replace(',', '.', 100 * $count/$ratings.count)}%;"></div>
                        </div>
                    </td>
                    <td>{$wa->shop->ratingHtml($rating)}</td>
                </tr>
                {/foreach}
            </table>
        {/if}
    {/if}
    <a name="reviewheader"></a>
    <!-- add review form -->
    <div class="write-review">
        <a href="#" class="e-reviews__link-write _button">{_w('Write a review')}</a>
    </div>
      <div class="review-form e-review-write wa-form" id="review-form" style="margin: 20px 0;{if $reviews_count > 0}display:none;{/if}">
        <form id="review-add-form" method="post" enctype="multipart/form-data">
            <div class="review-form-fields">
                {if !$wa->user()->isAuth() && $require_authorization}
                <div class="review-field wa-form__auth-line">{sprintf(_w('To add a review please <a href="%s">sign up</a> or <a href="%s">login</a>'), $wa->signupUrl(), $wa->loginUrl())}</div>
                {else}
                {if $wa->user()->isAuth()}
                <div class="review-field wa-form__auth-line"><label>{_w('Your name')}</label>
                      <img src="{$wa->user()->getPhoto(20)}" class="userpic" alt="">
                    <strong>{$wa->user('name')}</strong>
                    <a href="?logout">{_w('log out')}</a>
                </div>
                {else}
                <div class="provider-fields">
                  <div class="review-field e-review-write__line">
                      <div class="e-review-write__name">
                        <label>{_w('Your name')}</label>
                      </div>
                      <div class="e-review-write__control">
                        <input {if !empty($errors.name)}class="error"{/if} type="text" name="name" id="review-name" value="{$wa->post('name', '')|escape}">
                        {if !empty($errors.name)}<em class="errormsg">{$errors.name}</em>{/if}
                        </div>
                  </div>
                  <div class="review-field e-review-write__line">
                    <div class="e-review-write__name">
                        <label>[`Email`]</label>
                    </div>
                    <div class="e-review-write__control">
                        <input {if !empty($errors.email)}class="error"{/if} type="text" name="email" id="review-email" value="{$wa->post('email', '')|escape}">
                        {if !empty($errors.email)}<em class="errormsg">{$errors.email}</em>{/if}
                    </div>
                  </div>                                              
                    {if !empty($reviews_settings.enable_photo_upload)}
                    <p class="review-field">
                        <label>[`User's photo`]</label>
                        <input type="file" name="image" accept="image/gif,image/jpeg,image/png">
                    </p>
                    {/if}
                </div>
                {/if}
                {if !empty($enable_rating)}
                <div class="review-field e-review-write__line e-review-write__line_stars">
                    <div class="e-review-write__name">
                      <label>[`Rating`]</label>
                      <span class="e-review-write__stars">
                        <a href="#" class="no-underline rate" data-rate="0" id="reviews-rate">
                            {$wa->shop->ratingHtml(0, 16, true)}
                        </a>
                        <a href="javascript:void(0);" class="inline-link rate-clear" id="clear-reviews-rate" style="display: none;">
                          <b>×</b>
                        </a>
                        <input name="rating" type="hidden" value="0">
                      </span>                      
                      </div>
                </div>
                {/if}
                <div class="review-field e-review-write__line">
                  <div class="e-review-write__name">
                    <label for="review-text">{_w('Review')}</label>
                  </div>
                  <div class="e-review-write__control">
                    <textarea id="review-text" name="text" rows="10" cols="45" required></textarea>
                  </div>
                </div>
                {if !empty($reviews_settings.enable_photos_upload)}
                <p class="review-field">
                    <label for="review-text">[`Photos`]</label>
                    <input class="review-images-input" type="file" name="images[]" accept="image/gif,image/jpg,image/jpeg,image/png" multiple>
                    <span class="hint">Можно выбрать несколько файлов удерживая кнопку CTRL</span>
                </p>
                {/if}
                <div class="review-submit">
                    {if $require_captcha && !$wa->user()->isAuth()}
                    {$wa->captcha([], ifset($errors.captcha))}
                    {/if}
                    <input type="submit" class="save" value="{_w('Add review')}">
                    <span class="review-add-form-status ajax-status" style="display: none;">
                        <i class="icon16 loading"><!--icon --></i>
                    </span>
                </div>
                {/if}
            </div>
        </form>
    </div>
  
      <div class="e-reviews-list">
      {foreach $reviews as $review}
      <div class="e-reviews-list__item" itemprop="review" itemscope itemtype="http://schema.org/Review">
        <div class="e-reviews-list__left">
            <div class="e-reviews-list__contacts">
                <span class="e-reviews-list__name">
                    <a itemprop="author">{$review.name}</a>
                </span>
            </div>
            <div class="e-reviews-list__date _hint" itemprop="datePublished" content="{$review.datetime|date_format:'Y-m-d'}">{$review.datetime|wa_datetime:"humandatetime"}</div>
        </div>
        <div class="e-reviews-list__right">
            <div class="e-reviews-list__right-wrap">
                <div class="e-reviews-list__general">
                      {if !empty($review.rating)}
                    <div class="e-reviews-list__title">                        
                      {$rate = round($review.rating)}
                      <span class="e-reviews-list__stars" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
                        <meta itemprop="worstRating" content = "1">
                        <meta itemprop="ratingValue" content="{$rate}">
                        <meta itemprop="bestRating" content = "5">
                        {$wa->shop->ratingHtml($rate)}
                      </span>
                      </div>
                    {/if}                                        
                      <div class="e-reviews-list__text" itemprop="description">
                        {$review.text}
                      </div>
                    {if !empty($review.images)}
                    <div class="images">
                        {foreach $review.images as $_img}
                        <div class="image">
                            <img alt="" src="{$wa_url}wa-data/public/shop/reviews/{$review.id}_{$_img}">
                        </div>
                        {/foreach}
                    </div>
                    {/if}                  
                      {if $review.response}
                          <div class="e-reviews-list__comments">
                          <div class="e-reviews-list__comments-item">
                              <div class="e-reviews-list__comments-zag">
                                  <i class="fa fa-reply _hint" aria-hidden="true"></i> 
                                  <span class="e-reviews-list__comments-name">
                                      {if !empty($enable_response_info) && !empty($review.response_contact)}
                                          {$review.response_contact.firstname}
                                      {else}
                                          [`Response`]
                                      {/if}
                                  </span>
                                  <span class="e-reviews-list__comments-staff">({$wa->shop->settings('name')})</span>
                                  {if !empty($enable_response_info) && !empty($review.response_datetime)}
                                  <span class="e-reviews-list__comments-date _hint">
                                      {$review.response_datetime|wa_datetime:"humandatetime"}
                                  </span>
                                  {/if}
                              </div>
                              <div class="e-reviews-list__comments-text">
                                {$review.response}
                              </div>
                          </div>                          
                          </div>
                      {/if}
                  </div>  
              </div>  
        </div>
      </div>
      {/foreach}
      </div>
    {wa_pagination total=$pages_count attrs=['class' => "menu-h"] url="{$wa->getUrl('/frontend/reviews')}"}
</div>
{if !empty($enable_rating)}
<script type="text/javascript">
    $(function () {
        $.getScript("{$wa_app_static_url}js/rate.widget.js", function () {
            $('#reviews-rate').rateWidget({
                onUpdate: function(rate) {
                    $('#review-add-form input[name="rating"]').val(rate);
                }
            });
        });
    });
</script>
{/if}
{if !waRequest::isXMLHttpRequest() && waRequest::method() != 'post'}
<script type="text/javascript">
    $(function () {
        $(".reviews").on('click', ".write-review a", function () {
            $("#review-form").show();
            $("#review-form input:first").focus();
            return false;
        });
        $(".reviews").on('submit', "#review-add-form", function () {
            $(".review-add-form-status").show();
            var f = function (response) {
                $(".review-add-form-status").hide();
                if (response.status == 'ok') {
                    var tmp = $('<div></div>').append(response.data);
                    $(".reviews").html(tmp.find('.reviews').html());
                    {if !empty($enable_rating)}$('#reviews-rate').rateWidget({ onUpdate: function(rate) { $('#review-add-form input[name="rating"]').val(rate);}});{/if}
                } else if (response.status == 'fail') {
                    $(".reviews em.errormsg").remove();
                    $(".reviews .error").removeClass('error');
                    for (var k in response.errors) {
                        if (k == 'captcha') {
                            var el = $(".wa-captcha-input");
                        } else {
                            var el = $("#review-" + k);
                        }
                        el.addClass('error');
                        if (!el.next().is('em.errormsg')) {
                            $('<em class="errormsg"></em>').insertAfter(el);
                        }
                        el.next().html(response.errors[k]);
                    }
                }
            };
            if ($(this).find('input:file').length) {
                if (!$('#reviews-add-iframe').length) {
                    $('<iframe name="reviews-add-iframe" id="reviews-add-iframe" style="display: none"></iframe>').insertAfter($(this));
                }
                $(this).attr('target', 'reviews-add-iframe');
                $("#reviews-add-iframe").one('load', function () {
                    try {
                        var data = $(this).contents().find('body').text();
                        var response = $.parseJSON(data);
                    } catch (e) {
                        return;
                    }
                    f(response);
                });
                return true;
            } else {
                $.post("?", $(this).serialize(), f, "json");
            }
            return false;
        });
    });
</script>
{/if}

Опубликовано: 31 мая 2019
Эта статья была полезна? Да Нет

0 комментариев

    Добавить комментарий

    Чтобы добавить комментарий, зарегистрируйтесь или войдите