Hi.

When I add the following to node.tpl.php, the first 'option image' pic appears, but the images do not change when a different attribute is selected. Any suggestions on what I need to add to get it working? Thanks!

print $node->content['option_image']['#value']; 

I need to do it without using: print $content

CommentFileSizeAuthor
#7 uc_option_image.js_.patch509 bytescangeceiro

Comments

tjholowaychuk’s picture

Hello, I cant confirm at this moment but uc_option_image does require some of the same markup generated by a 'default' Drupal install, such as

etc since it requires traversing specific DOM elements in order to know which select field switching which image etc. As far as printing the initial image, what you have looks like it should be good!
tjholowaychuk’s picture

Status: Active » Fixed

I just did a quick test using the code below and it seem to be working. I would assume this is an issue with the JavaScript markup dependencies ( I will be documenting this as this seems to be a common problem )

    <?php print $node->content['option_image']['#value'] ?>
    <?php print $node->content['add_to_cart']['#value'] ?>
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

rvarkonyi’s picture

Hi!

I really like your module, it works great!

I'm in a theming problem too, I get the same problems but only when I place <?php print $node->content['option_image']['#value'] ?> in a <div> . If it's not in a <div> the images switch ok. Is there any chance it could work in a <div> ?

Thanks!

Rob

brotkel’s picture

I've found that the function that switches the image is very hierarchy dependent. It requires that the input and the image are in the same container in the DOM and that the container has the class "content", which works fine if you're just using the raw content, but not if you theme the page so that the add_to_cart section isn't in the same place as the image, or if you're not adding the content class as the parent of both items.

To fix this, I just removed the hierarchy. In uc_option_images.js, find this on line 37:
var image = $(input).parents('.content').children('img.uc-option-image');
and change it to this:
var image = $('img.uc-option-image');
.

I haven't extensively tested this with multiple options, so I don't know if it will cause issues for other people, but it works fine for my store.

Militopedia’s picture

Hi brotkel,

Thanks for the solution. I am using Drupal 6 and tried to solve the same problem. In Firefox it worked without a fix, but it didn't work with IE. I don't understand js but here's what I changed in uc_option_image.js:

I replaced

image = $(':not(.uc-option-image-preloaded) > div.uc-option-image-block').children('img.uc-option-image');

with

image = $(':not(.uc-option-image-preloaded) > div.uc-option-image-block')>('img.uc-option-image');

It worked now in IE, HOWEVER, the fade effect doesn't work anymore.

Do you know why and how I could correct this so that the fade effect still works?

Thanks!
Roger

cangeceiro’s picture

StatusFileSize
new509 bytes

Attached is the fix in #5 in patch form. It would be great to have this committed to the source tree. Is there any reason that it needs to be hierarchical? This creates lots of problems when it comes to theming.

jazzitup’s picture

Status: Closed (fixed) » Needs review

Marking as "needs review".

acouch’s picture

Status: Needs review » Closed (won't fix)

The 5.x version is no longer being supported for this module. We are cleaning up the 6.x version and preparing for the 7.x version.