Display image title in product > show_block_img

  • Posts: 56
  • Thank you received: 0
11 years 4 months ago #120315

I want to display the current images title in the product > show_block_img view. I was able to achieve this on page load by adding

<div id="title"><?php echo $image->file_name ?></div>
below my image. However I need to find a way to trigger it onmouseover for the thumbnails, like the "hikashopChangeImage" function does for the a class "hikashop_image_small_link".

bellaraejewelry.com/joomla/index.php?opt...ame=se-04&Itemid=159

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

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
11 years 4 months ago #120372

Only the image itself is updated on mouse over. To add the refresh of the name, that won't be easy. You'll have to add that in the javascript code of the display function of the file administrator/components/com_hikashop/helpers/image.php

The following user(s) said Thank You: Lutya

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

  • Posts: 56
  • Thank you received: 0
11 years 3 months ago #120444

Thank you so much! That's what I needed to get this done.

For future reference:

On line 201 of the image.php file, where the function hikashopChangeImage is defined, you need to add a way to dynamically change the innerHTML of the element that contains the ID of the title of your image. So for my <div id="title"><?php echo $image->file_name ?></div> that I added to my product > show_block_img view to change with the new displayed image, I added:

title = document.getElementById(\'title\');
	if(title){
		if(nAlt) title.innerHTML=nTitle;
	}

Just below line 233 of the image.php file.

It was actually a pretty simple solution once I new the correct php file to edit.

Last edit: 11 years 3 months ago by Lutya.

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

  • Posts: 10
  • Thank you received: 0
11 years 3 months ago #120776

Could you have not added to the show_block_img;

<div id="ImgTitle" onmouseover="showTitle();" onmouseout="hideTitle();"><?php echo $image->file_name ?></div>

Then just add a function to your base Index Template of;

function showTitle()
{
   var ImgTitle = document.getElementById('ImgTitle');
   ImgTitle.style.display = 'block';
}

function hideTitle()
{
   var ImgTitle = document.getElementById('ImgTitle');
   ImgTitle.style.display = 'none';
}

That way you could stylize the div to suit your needs and just have it show and unshow on hover.
Also, this reduces the amount of "hacking" you need to do to base files for HikaShop for when you update it.

.: ETA :.
Oh, you'd need to add to the default CSS of the #ImgTitle that its 'display' is initially set to 'none' so that it isn't visible before hover.

Last edit: 11 years 3 months ago by Sovaka. Reason: Fixed some code reference errors.

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

  • Posts: 56
  • Thank you received: 0
11 years 3 months ago #120777

If you put the onmouseover event in the div containing the title, then the title wouldn't change unless the user moused over that title - not the thumbnail. If you put the onmouseover event in the thumbnail (like the hikashopChangeImage function is) then it doesn't work for some reason - probably something to do with the PHP on the page setting the attributes you are pulling. I had to actually include it in the hikashopChangeImage function defined in the php file "image.php".

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

  • Posts: 10
  • Thank you received: 0
11 years 3 months ago #120778

Hmm good point, sorry about that mistake.
However you can still get around it by placing the 'show_image_block' within a <div id="ShowImgTitle" onmouseover="showTitle();" onmouseout="hideTitle();"><?php "show_block_image" ?></div>
Then using the same function code as above, it will result in a Hover Div display over the Image but will be triggered by the image itself essentially.

.: ETA :.
Though to be honest, your code is a whole lot simpler to achieve the same result.
That being said, you'll just need to take note of "how, where and what" you did to get the result for when you update HikaShop next.

I have a similar issue with my modifications I have done to Kunena.

It's a pain in the arse.

Last edit: 11 years 3 months ago by Sovaka. Reason: ETA

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

  • Posts: 56
  • Thank you received: 0
11 years 3 months ago #120779

That might actually work... except it might try to trigger before the thumbnail changes the image since the thumbnails are contained in show_block_image. This would result in it pulling the title tag for the old image.

Either way, the simple adjustment to the php worked just fine.

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

  • Posts: 10
  • Thank you received: 0
11 years 3 months ago #120780

Yeah, you'd have to add a subsection for the Thumbnail version and you'd need to parameterize the ShowImgTitle.
So if you had multiple of img blocks, it wouldn't trigger all of their div popups :p

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

Time to create page: 0.079 seconds
Powered by Kunena Forum