Проблема Не работают миниатюры в карточке товара

Тема в разделе "Дизайн и оформление, шаблоны", создана пользователем Syas, 23.12.2015.

  1. Offline

    Syas Пользователь

    Регистрация:
    15.10.2011
    Сообщения:
    48
    Симпатии:
    2
    Пол:
    Мужской
    Проблема такая не работают миниатюры в карточке товара.
    То есть при нажатии на миниатюру главная картинка меняется.
    Код привел в такой вид
    Код (PHP):
    1. <?php
    2. /**
    3. *
    4. * Show the product details page
    5. *
    6. * @package    VirtueMart
    7. * @subpackage
    8. * @author Max Milbers, Valerie Isaksen
    9.  
    10. * @link http://www.virtuemart.net
    11. * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
    12. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
    13. * VirtueMart is free software. This version may have been modified pursuant
    14. * to the GNU General Public License, and as distributed it includes or
    15. * is derivative of works licensed under the GNU General Public License or
    16. * other free or open source software licenses.
    17. * @version $Id: default_images.php 6188 2012-06-29 09:38:30Z Milbo $
    18. */
    19. // Check to ensure this file is included in Joomla!
    20. defined('_JEXEC') or die('Restricted access');
    21. if(VmConfig::get('usefancy',1)){
    22.     vmJsApi::js( 'fancybox/jquery.fancybox-1.3.4.pack');
    23.     vmJsApi::css('jquery.fancybox-1.3.4');
    24.     $document = JFactory::getDocument ();
    25. /*    $imageJS = '
    26.     jQuery(document).ready(function() {
    27.     jQuery("a[rel=vm-additional-images]")
    28.     .fancybox({
    29.             "titlePosition"     :"inside",
    30.             "transitionIn"    :    "elastic",
    31.             "transitionOut"    :    "elastic"
    32.         });
    33.  
    34.           jQuery(".additional-images a.product-image.image-0").removeAttr("rel");
    35.         jQuery(".additional-images img.product-image").click(function() {
    36.             jQuery(".additional-images a.product-image").attr("rel","vm-additional-images" );
    37.             jQuery(this).parent().children("a.product-image").removeAttr("rel");
    38.             var src = jQuery(this).parent().children("a.product-image").attr("href");
    39.             jQuery(".main-image img").attr("src",src);
    40.             jQuery(".main-image img").attr("alt",this.alt );
    41.             jQuery(".main-image a").attr("href",src );
    42.             jQuery(".main-image a").attr("title",this.alt );
    43.             jQuery(".main-image .vm-img-desc").html(this.alt);
    44.         });
    45.     });
    46.     ';   */
    47. $imageJS = '
    48. var j$ = jQuery.noConflict();
    49. j$(document).ready(function() {
    50.    j$("a[rel=vm-additional-images]").fancybox({
    51.        "titlePosition" : "inside",
    52.        "transitionIn" : "elastic",
    53.        "transitionOut" : "elastic"
    54.    });
    55. });
    56.  
    57.          jQuery(".additional-images a.product-image.image-0").removeAttr("rel");
    58.        jQuery(".additional-images img.product-image").click(function() {
    59.            jQuery(".additional-images a.product-image").attr("rel","vm-additional-images" );
    60.            jQuery(this).parent().children("a.product-image").removeAttr("rel");
    61.            var src = jQuery(this).parent().children("a.product-image").attr("href");
    62.            jQuery(".main-image img").attr("src",src);
    63.            jQuery(".main-image img").attr("alt",this.alt );
    64.            jQuery(".main-image a").attr("href",src );
    65.            jQuery(".main-image a").attr("title",this.alt );
    66.            jQuery(".main-image .vm-img-desc").html(this.alt);
    67.        });
    68.  
    69.    ';
    70.  
    71. } else {
    72.     vmJsApi::js( 'facebox' );
    73.     vmJsApi::css( 'facebox' );
    74.     $document = JFactory::getDocument ();
    75.     $imageJS = '
    76.    jQuery(document).ready(function() {
    77.        jQuery("a[rel=vm-additional-images]").facebox();
    78.  
    79.        var imgtitle = jQuery("span.vm-img-desc").text();
    80.        jQuery("#facebox span").html(imgtitle);
    81.  
    82.  
    83.    });
    84.    ';
    85. }
    86. $document->addScriptDeclaration ($imageJS);
    87.  
    88. if (!empty($this->product->images)) {
    89.     $image = $this->product->images[0];
    90.     ?>
    91.     <div class="main-image">
    92. <?php echo $image->displayMediaFull("",true,"rel='vm-additional-images'"); ?>
    93.         <div class="clear"></div>
    94.     </div>
    95.     <?php
    96.     $count_images = count ($this->product->images);
    97.     if ($count_images > 1) {
    98.         ?>
    99.         <div class="additional-images">
    100.             <?php
    101.             $start_image = VmConfig::get('add_img_main', 1) ? 0 : 1;
    102.             for ($i = $start_image; $i < $count_images; $i++) {
    103.                 $image = $this->product->images[$i];
    104.                 ?>
    105.                 <div class="floatleft">
    106.  
    107.  
    108.                     <?php
    109.                     if(VmConfig::get('add_img_main', 1)) {
    110.                         echo $image->displayMediaThumb('class="product-image" style="cursor: pointer"',false,"");
    111.                         echo '<a href="'. $image->file_url .'"  class="product-image image-'. $i .'" style="display:none;" title="'. $image->file_meta .'" rel="vm-additional-images"></a>';
    112.                     } else {
    113.                         echo $image->displayMediaThumb("",true,"rel='vm-additional-images'");
    114.                     }
    115.                     ?>
    116.                 </div>
    117.             <?php
    118.             }
    119.             ?>
    120.             <div class="clear"></div>
    121.         </div>
    122.     <?php
    123.     }
    124. }
    125. // Showing The Additional Images END ?>

    и в шаблоне подключил fancybox и jquery
    Код (PHP):
    1. $this->addScript($this->baseurl.'/templates/'.$this->template.'/js/fancybox/jquery.fancybox-1.3.4.pack.js');
    2. $this->addScript($this->baseurl.'/templates/'.$this->template.'/js/fancybox.js');

    Помогите разобраться что там мешает срабатыванию скрипта
     
    Последнее редактирование: 02.11.2020
  2.  

Поделиться этой страницей

Загрузка...