Display product option's image in the tooltip

  • Posts: 22
  • Thank you received: 1
8 years 1 month ago #253774

-- 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

$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!

Attachments:
Last edit: 8 years 1 month ago by Lippo.

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

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
8 years 1 month ago #253798

Hi,

Try it like that:
$description = JHTML::_('content.prepare',$optionInfo->product_description);

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

  • Posts: 22
  • Thank you received: 1
8 years 1 month ago #253863

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?

Attachments:

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

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
8 years 1 month ago #253895

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

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

  • Posts: 22
  • Thank you received: 1
8 years 1 month ago #253905

Hi Nicolas,

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.

  • Posts: 22
  • Thank you received: 1
8 years 1 month ago #253917

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:

$html = '<span class="hikashop_option_name">'.$optionInfo->product_name.$options.'</span></td><td>' . $html;

with:
$html = '<span class="hikashop_option_name">'.$optionInfo->product_description.$options.'</span></td><td>' . $html;

Result attached

Attachments:
The following user(s) said Thank You: Jerome

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

  • Posts: 170
  • Thank you received: 8
  • Hikashop Essential
1 month 1 week ago #364514

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

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

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
1 month 1 week ago #364516

Hi,

The code did change a bit, but it's mainly still the same.
The code is now:

			<span class="hikashop_option_name"><?php
				echo $optionInfo->product_name . $options;
			?></span>
in the view product / option, which you can change to:
			<span class="hikashop_option_name"><?php
				echo $optionInfo->product_description . $options;
			?></span>
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.

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

  • Posts: 170
  • Thank you received: 8
  • Hikashop Essential
1 month 1 week ago #364537

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

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

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
1 month 1 week ago #364539

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 ?

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

  • Posts: 170
  • Thank you received: 8
  • Hikashop Essential
1 month 6 days ago #364553

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

Attachments:
Last edit: 1 month 6 days ago by ianspeed.

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

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
1 month 6 days ago #364560

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:

			<span class="hikashop_option_name"><?php
				echo $optionInfo->product_option_label.$optionInfo->product_name. $options;
			?></span>
- 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.

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

Time to create page: 0.083 seconds
Powered by Kunena Forum