- Posts: 640
- Thank you received: 16
Insert product image in product layout
- PeterChain
-
Topic Author
- Offline
What code to insert a product image in the product layout?
My image names they all follow this pattern:
(product_code)-01
(product_code)-03
(product_code)-03
I want to insert in a certain place image -01 with my own size not depending on the HikaShop parameters for iamge and thumbnails.
Please Log in or Create an account to join the conversation.
You just have to edit the view "product / show_default" from the Display > Views menu, and add the html tag to display the image.
Something like:
Please Log in or Create an account to join the conversation.
- PeterChain
-
Topic Author
- Offline
- Posts: 640
- Thank you received: 16
How to check for the availability fo the picture?
For some products I have 10 pictures, for others 5, so I need the check code for each picture before publishing.
Could you be so kind to help me with this?
Please Log in or Create an account to join the conversation.
You can use JFile::exists function, like:
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.
Please Log in or Create an account to join the conversation.
- PeterChain
-
Topic Author
- Offline
- Posts: 640
- Thank you received: 16
all this help was successful so big thanks for it!
But now a new problem comes with this.
My client is in love with HikaMarket drag and drop feature and is changing the sequence of pictures so not always the product_name-01 picture is the first one to be shown. This means that I need a way to get the names of the pictures not by my logical ordering system but by the way they are ordered in hikamarket (or whatever in admin).
I mean, this:
<img src="<?php echo 'imagePath/'.$this->element->product_code.'-01.png';?>
should be somehow converted to this:
<img src="<?php echo 'imagePath/'.$this->element-> (name of picture by its order of appearance number) '; ?>
or better explained
<img src="<?php echo first_picture;?>
<img src="<?php echo second_picture;?>
<img src="<?php echo third_picture;?>
...
Please Log in or Create an account to join the conversation.
So you do not want at all display some pre-defined images but you want to display the product images, like the view "show_block_img" does, right ?
In the product page, you can access to "$this->element->images" array which contains all images in the right order.
You can take a look at the view "product | show_block_img" and see own the thumbnails images are displayed at the end of the view.
Using the help image is not an obligation, you can just use the objects "$image" to get the file_path information (and file_name).
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.
Please Log in or Create an account to join the conversation.
- PeterChain
-
Topic Author
- Offline
- Posts: 640
- Thank you received: 16
Please Log in or Create an account to join the conversation.
- PeterChain
-
Topic Author
- Offline
- Posts: 640
- Thank you received: 16
http://localhost:8888/activacions/%3Ca%20title=
Could somebody please help me tune-up this small piece of code, I'm pretty sure it must be some very stupid flaw in my coding.
Thank you
Please Log in or Create an account to join the conversation.
Using the function "$this->image->display()" will display the image with all HikaShop features (thumbnail + popup).
You are mixing two different and incompatibles way to display an image. So it could not work.
So, you can display images by creating the "<img/>" tag yourself or you can use the HikaShop helper image. But not both in the same time.
The fast fix is to replace:
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.
Please Log in or Create an account to join the conversation.
- PeterChain
-
Topic Author
- Offline
- Posts: 640
- Thank you received: 16
THANK YOU A LOT! You're a great team!
Please Log in or Create an account to join the conversation.
I am trying your code with no avail. Could you help, this is the code I am using
Could you please help.
Cheers
Iain
Please Log in or Create an account to join the conversation.
The code looks fine.
Could you provide a link to a product page so that we can see the result ?
Please Log in or Create an account to join the conversation.
Yes the website is craven-equipment.co.uk/index.php/luggage.../21-comet-black-left
Cheers
Iain
Please Log in or Create an account to join the conversation.
So in your code you have:
<div id="hikashop_product_right_part" class="hikashop_product_right_part hkc-md-6">
But if I look at your link, I see that:
monosnap.com/file/BILLsjh9UWirGyjoOEMHyHTIvGjuI5
As you can see, the " hkc-md-6" part is missing.
So you're not adding your img tag in the correct view file.
Please use the "Display view files" setting of the HikaShop configuration to check which view file you need to modify.
Please Log in or Create an account to join the conversation.
Cheers
Iain
Please Log in or Create an account to join the conversation.
It could be show_default, or show_reverse or show_tabular or a custom show_ file you might have.
The Display view files setting will tell you which view file is used for the display of the area where you want to add your code.
Please Log in or Create an account to join the conversation.