Image Rotator on Product Page

  • Posts: 131
  • Thank you received: 7
11 years 2 months ago #121389

Hello,

I'm using 2.2.1 on Joomla 2.5

My client has asked me to implement a customisation to the product page that will automatically rotate through the images (with a fade effect) for the product.

I found this plug-in : www.orware.com/products/very-simple-image-rotator-plugin

Which would appear to be so simple to use with Hikashop, so I installed, enabled it and modified the show_block_img.php to call it with the path to the product images using:-

{vsir randomizeImagesNo directImageLinksNo setDelay 5000 setTransitionDelay 2000 <?php $image->file_path ?>}

However the plug-in never gets called. I am wondering whether this is because the product page does not automatically call content plug-ins with "prepare content".

I know that I can use system plug-ins as I also use Modules Anywhere, but clearly in this case I need to be able to supply the path to the images for the product.

Is there a solution?

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
11 years 2 months ago #121468

Hi,

Content plugins are called on the content. In the case of the hikashop product page, the content plugins are called for the product description, and not for the whole page, as it should be.
So the solution in your case is to call the content plugins your self on your tag:
<?php echo JHTML::_('content.prepare','{vsir randomizeImagesNo directImageLinksNo setDelay 5000 setTransitionDelay 2000 '. $image->file_path.'}'); ?>

The following user(s) said Thank You: bonzomedia, DeeEmm

Please Log in or Create an account to join the conversation.

  • Posts: 131
  • Thank you received: 7
11 years 2 months ago #121483

NIcolas

Beautiful! Plug-in gets called and works a treat!

BUT I now realise that the images for each product are not handily stored in a subdirectory but instead are referenced from all of the images of that particular size in the uploads/thumbnails directory. This means that I can't simply point the vsir plugin at a subdirectory.

So, to make it work I have to create a seperate images directory for each of the products that need to use the rotator. I'm using the product_code (which Hikashop forces to be unique) as the directory name and my code checks to see if this directory exists. If it does, the image rotator is called, if not, the normal hikashop single image display is called.

Although it's manageable, ideally it would be really good if hikashop shipped with an image rotator that can be enabled or disable on a per product basis.

If anyone else would like to use the technique I've used, I'm happy to share the code that I implemented in the View -> show_block_img.php

At the top of the file, set up the path (I'm using the [root]/images directory with subdirectories using the same name as the Product Code

/**
 * bonzomedia - image rotator path set up
 */
  $rotator_image_path = 'images/'.$this->element->main->product_code;
?>

Further down in show_block_img.php I test to see if the subdirectory exists, if it does I assume that the product images for the rotator have been placed in this directory and call the plug-in. If the directory does not exist I revert back to the standard Hikashop display.
<div class="hikashop_product_main_image_thumb" id="hikashop_image_main_thumb_div<?php echo $variant_name;?>" <?php echo $style;?> >
          <div style="<?php if(!empty($divHeight)){ echo 'height:'.($divHeight+20).'px;'; } ?>text-align:center;clear:both;" class="hikashop_product_main_image">
            <div style="position:relative;text-align:center;clear:both;<?php if(!empty($divWidth)){ echo 'width:'.$divWidth.'px;'; } ?>margin: auto;" class="hikashop_product_main_image_subdiv">
              
              <?php
              if (file_exists($rotator_image_path))
                  echo JHTML::_('content.prepare','{vsir '.$rotator_image_path .'}');
              else
              echo $this->image->display(@$image->file_path,true,@$image->file_name,'id="hikashop_main_image'.$variant_name.'" style="margin-top:10px;margin-bottom:10px;display:inline-block;vertical-align:middle"','id="hikashop_main_image_link"', $width,  $height);
              
              
              if(!empty($this->element->badges))
                $this->classbadge->placeBadges($this->image, $this->element->badges, '0', '0');
            ?>
            </div>
          </div>
        </div>

The following user(s) said Thank You: nicolas, DeeEmm

Please Log in or Create an account to join the conversation.

  • Posts: 131
  • Thank you received: 7
11 years 2 months ago #122338

I am continuing to build out the product catalog for this project.

However, I am seeing an issue with a few products whereby the following PHP statement is not obtaining the product code:-

$rotator_image_path = 'images/'.$this->element->main->product_code;

This is despite the product code being shown in the backend in the product listing, in these circumstances the method is returning NULL.

Am I using the correct method in show_block_img.php to get the product code? Why is it working for some (most) and not others?

Thanks!

Please Log in or Create an account to join the conversation.

  • Posts: 26159
  • Thank you received: 4028
  • MODERATOR
11 years 2 months ago #122402

Hi,

"$this->element->main" is for accessing to the main product when you have characteristics/variants.
If the product does not have variants/characteristics, so there won't have any "$this->element->main" or "$this->element->main->product_code" and you have to get the product_code in the product itself "$this->element->product_code".

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: bonzomedia

Please Log in or Create an account to join the conversation.

  • Posts: 131
  • Thank you received: 7
11 years 2 months ago #122423

Thanks Jerome - that explains it, but seems a little illogical - surely that data element should contain the main product_code irrespective of whether it has variants or not?!

Anyway, looks like I'll need to make a test to see if there are zero or more variants and use the different data elements to build my path.

Is there a function/data element that returns the number of variants for a product?

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 131
  • Thank you received: 7
11 years 2 months ago #122429

OK got it!

sizeof($this->element->variants);

Please Log in or Create an account to join the conversation.

Time to create page: 0.068 seconds
Powered by Kunena Forum