[Решено] Ссылка на отзывы с переключением вкладки

Тема в разделе "OpenCart", создана пользователем KuEdA, 5 авг 2015.

Статус темы:
Закрыта.
  1. KuEdA

    KuEdA

    Регистрация:
    20 сен 2014
    Сообщения:
    194
    Симпатии:
    36
    Здравствуйте. Подскажите, пожалуйста, как сделать ссылку на отзывы из категории товаров и поиска, чтобы при нажатии на нее открывалась вкладка отзывов в карте товара. Сайт: http://stylishjewel.ru/.

    Сделал в табах так, вставил в product_tab.tpl:

    <a href="<?php echo $product['href']; ?>#tab-review"><?php echo $product['reviews']; ?></a>

    В product.tpl вставил:

    <script type="text/javascript">
    $(function () {
    var hash = $.trim( window.location.hash );
    if (hash) $('#tabs a[href$="'+hash+'"]').trigger('click');
    });
    </script>

    Все работает, выводится ссылка на отзывы с якорем "На основе отзывов". Но в категориях category.tpl, у меня внизу располагается скрипт owl карусели:

    Код:
      <script type="text/javascript"><!--
    function display(view) {
        if (view == 'list') {
            $('.product-grid').attr('class', 'product-list');
         
            $('.product-list > div').each(function(index, element) {
             
             
                html  = '<div class="left">';
             
               
                html += '<div class="owl-addimagecat owl-carousel">';
                        
                var image = $(element).find('.image').html();
                if (image != null) {
                    html += '<div class="image">' + image + '</div>';
                }
             
                            var image2 = $(element).find('.image0').html();
                if (image2 != null) {
                html += ' <div class="image image0">' + image2 + '</div>';
             
                }
                            var image2 = $(element).find('.image1').html();
                if (image2 != null) {
                html += ' <div class="image image1">' + image2 + '</div>';
             
                }
                            var image2 = $(element).find('.image2').html();
                if (image2 != null) {
                html += ' <div class="image image2">' + image2 + '</div>';
             
                }
                            var image2 = $(element).find('.image3').html();
                if (image2 != null) {
                html += ' <div class="image image3">' + image2 + '</div>';
             
                }
                            var image2 = $(element).find('.image4').html();
                if (image2 != null) {
                html += ' <div class="image image4">' + image2 + '</div>';
             
                }
                            var image2 = $(element).find('.image5').html();
                if (image2 != null) {
                html += ' <div class="image image5">' + image2 + '</div>';
             
                }
                         
                html += '</div>';
              
             
                html += '</div>';
                         
                html += '<div class="centr">';
    
                html += ' <div class="name">' + $(element).find('.name').html() + '</div>';
    
                html += '  <div class="description">' + $(element).find('.description').html() + '</div>';
                var rating = $(element).find('.rating').html();
             
                if (rating != null) {
                    html += '<div class="rating">' + rating + '</div>';
                }
                html += '</div>';
                 
                html += '<div class="right">';
                var price = $(element).find('.price').html();
             
                if (price != null) {
                    html += '<div class="price">' + price  + '</div>';
                }
                html += '  <div class="cart">' + $(element).find('.cart').html() + '</div>';
             
                html += ' <div class="hover_but">';
    
                            html += '</div>';
             
                html += '</div>';
                         
                $(element).html(html);
            }); 
             $(".owl-addimagecat").owlCarousel({ navigation : true, pagination : false, singleItem : true }); 
         
            $('.display').html('<span class="iconlist"></span> <a onclick="display(\'grid\');" class="icongrid"></a>');
         
            $.totalStorage('display', 'grid');
        } else {
            $('.product-list').attr('class', 'product-grid');
         
            $('.product-grid > div').each(function(index, element) {
                html = '';
             
                html += '<div class=img_but>';
             
                html += '<div class="owl-addimagecat owl-carousel">';
                        
                var image = $(element).find('.image').html();
                if (image != null) {
                    html += '<div class="image">' + image + '</div>';
                }
             
                            var image2 = $(element).find('.image0').html();
                if (image2 != null) {
                html += ' <div class="image image0">' + image2 + '</div>';
             
                }
                            var image2 = $(element).find('.image1').html();
                if (image2 != null) {
                html += ' <div class="image image1">' + image2 + '</div>';
             
                }
                            var image2 = $(element).find('.image2').html();
                if (image2 != null) {
                html += ' <div class="image image2">' + image2 + '</div>';
             
                }
                            var image2 = $(element).find('.image3').html();
                if (image2 != null) {
                html += ' <div class="image image3">' + image2 + '</div>';
             
                }
                            var image2 = $(element).find('.image4').html();
                if (image2 != null) {
                html += ' <div class="image image4">' + image2 + '</div>';
             
                }
                            var image2 = $(element).find('.image5').html();
                if (image2 != null) {
                html += ' <div class="image image5">' + image2 + '</div>';
             
                }
                         
                html += '</div>';
                         
                html += ' <div class="hover_but">';
    
                            html += '</div>';
                         
                html += '</div>';
             
                html += '<div class="name">' + $(element).find('.name').html() + '</div>';
                html += '<div class="description">' + $(element).find('.description').html() + '</div>';
             
                var price = $(element).find('.price').html();
             
                if (price != null) {
                    html += '<div class="price">' + price  + '</div>';
                }
                         
                var rating = $(element).find('.rating').html();
             
                if (rating != null) {
                    html += '<div class="rating">' + rating + '</div>';
                                    html += '<div class="cart">' + $(element).find('.cart').html() + '</div>';
                }
                     
                $(element).html(html);
            }); 
             $(".owl-addimagecat").owlCarousel({ navigation : true, pagination : false, singleItem : true });     
            $('.display').html('<a onclick="display(\'list\');" class="iconlist"></a> <span class="icongrid"></span>');
         
            $.totalStorage('display', 'grid');
        }
    }
    
    view = $.totalStorage('display');
    
    if (view) {
        display(view);
    } else {
        display('grid');
    }
    //--></script>
    И ссылка с якорем, просто-напросто не выводится. Если я убираю строку: var rating = $(element).find('.rating').html();, то ссылка отображается, но тогда пропадают изображения товаров. Подскажите, пожалуйста, как правильно сделать, чтобы и фотографии не пропадали, и ссылки на отзывы выводились. Заранее огромное спасибо.

    --- Добавлено, 5 авг 2015 ---
    Решил проблему следующим образом:
    Код:
     <div class="rating">
              <?php for ($i = 1; $i <= 5; $i++) { ?>
              <?php if ($product['rating'] < $i) { ?>
              <span class="fa fa-stack"><i class="fa fa-star-o fa-stack-2x"></i></span>
              <?php } else { ?>
              <span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i><i class="fa fa-star-o fa-stack-2x"></i></span>
              <?php } ?>
              <?php } ?>
    <br><a href="<?php echo $product['href']; ?>#tab-review"><?php echo $product['reviews']; ?></a>
            </div>        
    Нужно было просто разместить ссылку на отзывы в div'e.
     
Статус темы:
Закрыта.