- Posts: 22
- Thank you received: 1
Display product option's image in the tooltip
9 years 10 months ago - 9 years 10 months ago #253774
by Lippo
Display product option's image in the tooltip was created by Lippo
-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.6.4
-- PHP version -- : 5.6.27
-- Browser(s) name and version -- : Firefox 49.0.2
Hello,
found several discussions about that, but no one leading to a concrete solution for the problem/request.
Product options are additional products added to the main products.
Since the options are real products in HikaShop, they have also their product images.
Actually is not possible to show the image next to the optional product in the "options" list.
But, for each optional product we have the "description" displayed in a tooltip.
If i add an image in the description field, the image is not displayed.
Tried to look at the code and I found why, working through overrides.
file: option.php line 126
Actually, due to the "strips_tags" PHP function, all the HTML tages are stripped and plain text is shown in the tooltip.
If I try to use "allowable_tags" function coupled with strip_tags, in order to allow the image tags, it doesn't work.
If i remove "strips_tags" I see all the HTML code (product name + link to the image). Please remember that the image is included into the Product description (for each additional product). Output in the image attached.
What i'm not able to do is to display the "result" of the HTML code.
If the code will be treated as HTML, the image will be displayed in the tooltip.
Can you please help with this?
Thanks!
-- Joomla version -- : 3.6.4
-- PHP version -- : 5.6.27
-- Browser(s) name and version -- : Firefox 49.0.2
Hello,
found several discussions about that, but no one leading to a concrete solution for the problem/request.
Product options are additional products added to the main products.
Since the options are real products in HikaShop, they have also their product images.
Actually is not possible to show the image next to the optional product in the "options" list.
But, for each optional product we have the "description" displayed in a tooltip.
If i add an image in the description field, the image is not displayed.
Tried to look at the code and I found why, working through overrides.
file: option.php line 126
Code:
$description = $this->escape(strip_tags(JHTML::_('content.prepare',$optionInfo->product_description)));
Actually, due to the "strips_tags" PHP function, all the HTML tages are stripped and plain text is shown in the tooltip.
If I try to use "allowable_tags" function coupled with strip_tags, in order to allow the image tags, it doesn't work.
If i remove "strips_tags" I see all the HTML code (product name + link to the image). Please remember that the image is included into the Product description (for each additional product). Output in the image attached.
What i'm not able to do is to display the "result" of the HTML code.
If the code will be treated as HTML, the image will be displayed in the tooltip.
Can you please help with this?
Thanks!
Last edit: 9 years 10 months ago by Lippo.
Please Log in or Create an account to join the conversation.
9 years 10 months ago #253798
by nicolas
Replied by nicolas on topic Display product option's image in the tooltip
Hi,
Try it like that:
$description = JHTML::_('content.prepare',$optionInfo->product_description);
Try it like that:
$description = JHTML::_('content.prepare',$optionInfo->product_description);
Please Log in or Create an account to join the conversation.
9 years 10 months ago #253863
by Lippo
Replied by Lippo on topic Display product option's image in the tooltip
Hi Nicolas,
thank you for your answer.
Unfortunately it doesn't work.
It breaks the HTML tags and it still shows "unexpanded" html tags.
See the image attached.
Can you please provide other suggestions?
thank you for your answer.
Unfortunately it doesn't work.
It breaks the HTML tags and it still shows "unexpanded" html tags.
See the image attached.
Can you please provide other suggestions?
Please Log in or Create an account to join the conversation.
9 years 10 months ago #253895
by nicolas
Replied by nicolas on topic Display product option's image in the tooltip
Hi,
Then it means that the tooltips system doesn't support HTML tags.
You need to replace the line:
$options='<span class="hikashop_option_info" title="'.$description.'">'.$options.'</span>';
with a tooltip tag. For example: extensions.joomla.org/extension/tooltips
Then it means that the tooltips system doesn't support HTML tags.
You need to replace the line:
$options='<span class="hikashop_option_info" title="'.$description.'">'.$options.'</span>';
with a tooltip tag. For example: extensions.joomla.org/extension/tooltips
Please Log in or Create an account to join the conversation.
9 years 10 months ago #253905
by Lippo
Replied by Lippo on topic Display product option's image in the tooltip
Hi Nicolas,
in this case I should include the content of the option in the tip tag.
Can you suggest the syntax for this?
in this case I should include the content of the option in the tip tag.
Can you suggest the syntax for this?
Please Log in or Create an account to join the conversation.
9 years 10 months ago #253917
by Lippo
Replied by Lippo on topic Display product option's image in the tooltip
BTW fixed in a different way.
Decided to remove the tooltip and to display the product description (including the image) instead of the product title in the option box.
Changed this line:
with:
Result attached
Decided to remove the tooltip and to display the product description (including the image) instead of the product title in the option box.
Changed this line:
Code:
$html = '<span class="hikashop_option_name">'.$optionInfo->product_name.$options.'</span></td><td>' . $html;
with:
Code:
$html = '<span class="hikashop_option_name">'.$optionInfo->product_description.$options.'</span></td><td>' . $html;
Result attached
The following user(s) said Thank You: Jerome
Please Log in or Create an account to join the conversation.
1 year 10 months ago #364514
by ianspeed
Replied by ianspeed on topic Display product option's image in the tooltip
Hi Nicolas,
Hope you're well.
I am trying to replicate what Lippo did, with a thumbnail preceding the product options, I guess the code has changed over the last 8 years as I'm struggling to recreate what Lippo managed?
Any ideas on how to do this now?
Thanks
Ian
Hope you're well.
I am trying to replicate what Lippo did, with a thumbnail preceding the product options, I guess the code has changed over the last 8 years as I'm struggling to recreate what Lippo managed?
Any ideas on how to do this now?
Thanks
Ian
Please Log in or Create an account to join the conversation.
1 year 10 months ago #364516
by nicolas
Replied by nicolas on topic Display product option's image in the tooltip
Hi,
The code did change a bit, but it's mainly still the same.
The code is now:
in the view product / option, which you can change to:
via the Display>Views menu.
Note that this means that you want to add the thumbnail and the text in the description of your option product.
The code did change a bit, but it's mainly still the same.
The code is now:
Code:
<span class="hikashop_option_name"><?php
echo $optionInfo->product_name . $options;
?></span>
Code:
<span class="hikashop_option_name"><?php
echo $optionInfo->product_description . $options;
?></span>
Note that this means that you want to add the thumbnail and the text in the description of your option product.
Please Log in or Create an account to join the conversation.
1 year 10 months ago #364537
by ianspeed
Replied by ianspeed on topic Display product option's image in the tooltip
Hi Nicolas,
Unfortunately that isn't working for me, it just adds the current last image from the main product to the last option?
Am I missing some extra code somewhere else?
What I ideally would like is product image then product name and keep the tool tip for the option?
Thanks
Ian
Unfortunately that isn't working for me, it just adds the current last image from the main product to the last option?
Am I missing some extra code somewhere else?
What I ideally would like is product image then product name and keep the tool tip for the option?
Thanks
Ian
Please Log in or Create an account to join the conversation.
1 year 10 months ago #364539
by nicolas
Replied by nicolas on topic Display product option's image in the tooltip
Hi,
I don't see how that's possible. The code modification only adds the description of the option. It doesn't touch the image of the main product.
Are you sure you don't have other modifications ?
Can you provide a screenshot of what you changed ?
If you revert the change, can you confirm that you're back to just having the name of the option product ?
I don't see how that's possible. The code modification only adds the description of the option. It doesn't touch the image of the main product.
Are you sure you don't have other modifications ?
Can you provide a screenshot of what you changed ?
If you revert the change, can you confirm that you're back to just having the name of the option product ?
Please Log in or Create an account to join the conversation.
1 year 10 months ago - 1 year 10 months ago #364553
by ianspeed
Replied by ianspeed on topic Display product option's image in the tooltip
Hi Nicolas,
I've attached the screen shots, I removed all display modifications before changing the code. I've attached the the before, after and what I'm trying to achieve.
Thanks
Ian
I've attached the screen shots, I removed all display modifications before changing the code. I've attached the the before, after and what I'm trying to achieve.
Thanks
Ian
Last edit: 1 year 10 months ago by ianspeed.
Please Log in or Create an account to join the conversation.
1 year 10 months ago #364560
by nicolas
Replied by nicolas on topic Display product option's image in the tooltip
Hi,
So the modification does what it says it does:
It displays the description of the option product. It's just that you have the same description in the description of the option product as the description of the main product.
The simplest, to do what you want is:
- create a custom field of the table "product" and the column name "product_option_label" and of the type "WYSIWYG" via the menu Display>Custom fields.
- change the view override to use instead the code:
- then, edit the option product settings, and in the "product_option_label" custom field, enter the img tag for the image of the product when used as an option of another product.
So the modification does what it says it does:
It displays the description of the option product. It's just that you have the same description in the description of the option product as the description of the main product.
The simplest, to do what you want is:
- create a custom field of the table "product" and the column name "product_option_label" and of the type "WYSIWYG" via the menu Display>Custom fields.
- change the view override to use instead the code:
Code:
<span class="hikashop_option_name"><?php
echo $optionInfo->product_option_label.$optionInfo->product_name. $options;
?></span>
Please Log in or Create an account to join the conversation.
Time to create page: 0.265 seconds