Skip to main content

display next product image

More
10 years 5 months ago #238149 by kyratn
Hi,

What code I could use to add image for the next or previous product buttons?
My code looks something like this:
Code:
<a href="<?php echo $this->links->next;?>"><span class="pull-left"><i class='icon-angle-left'></i> <?php echo $this->links->next_product->product_name;?></span> <img src="NEXT_PRODUCT_IMG_PATH" height="145" width="115"></a>

Thanks

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

More
10 years 5 months ago #238241 by nicolas
Replied by nicolas on topic display next product image
Hi,

You'll need to add a MySQL query in order to load the data of the images from the hikashop_file table and then use the getThumbnail of the helper.image to generate the thumbnail and finally echo its URL inside the src of an img tag.

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

More
10 years 5 months ago #238361 by kyratn
Replied by kyratn on topic display next product image
Hi,

As usual thank you for replay Nicolas.
I see I need to do 3 things. Only one is the issue for me. How to add a MySQL query? Could you please give me some quick example?

Regards

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

More
10 years 5 months ago #238376 by nicolas
Replied by nicolas on topic display next product image
Hi,

It's quite easy actually:
Code:
<?php $db = JFactory::getDBO(); $db->setQuery('SELECT * FROM #__hikashop_file WHERE file_type=\'product\' AND file_ref_id=\''.(int)$this->links->next_product->product_id.'\''); $image = $db->loadObject(); ?>

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

More
10 years 2 weeks ago #251248 by FilipHradil
Hello, how can I show image then? :)


Thank you

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

More
10 years 2 weeks ago #251250 by Jerome
Replied by Jerome on topic display next product image
Hi,

You can take a look at the code in the view "product / show_block_image" and see how the image helper and the function getThumbnail can be used.

Regards,

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

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

More
10 years 2 weeks ago - 10 years 2 weeks ago #251294 by FilipHradil
Thank you. I did it!

Now it shows me image of next product.

Can you also advise me how to load next product of next product in this way?


Thís ís my current code:
Code:
$db->setQuery('SELECT * FROM #__hikashop_file WHERE file_type=\'product\' AND file_ref_id=\''.(int)$this->links->next_product->product_id.'\''); $img1 = $db->loadObject(); $img = $this->image->getThumbnail(@str_replace("-2","-1",$img1->file_path), array('width' => $width, 'height' => $height), $image_options); echo '<img class="'.$classname.'" title="'.$this->escape(@$img1->file_description).'" alt="'.$this->escape(@$img1->file_name).'" src="'.$img->url.'"/>';
Last edit: 10 years 2 weeks ago by FilipHradil.

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

More
10 years 2 weeks ago #251329 by nicolas
Replied by nicolas on topic display next product image
Hi,

The next product is not known. So it's more complex as it will require using a complex algorithm like there is in the components/com_hikashop/views/product/view.html.php file to initialize the $this->links variable but basing yourself on the $this->links->next_product variable instead of $this->element

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

Time to create page: 0.243 seconds
Powered by Kunena Forum