当访客在 Ubercart 中选择属性时更改产品图片

发布于 2024-09-12 07:56:58 字数 741 浏览 6 评论 0原文

当前设置

商店中的每个产品都有多个图像。当访问者访问产品页面时,他们会看到主图像和一系列缩略图(视图)。当他们单击缩略图时,该图像会立即显示在主图像区域中。

每个产品还有一个属性选择下拉列表,例如“颜色”。

Drupal / Ubercart 配置

我正在使用 Drupal 6。有一个产品内容类型,它具有文件类型的自定义图像字段。此图像字段接受多个值(即多个图像)。

然后,我使用视图(视图模块)来显示一系列缩略图,并使用 JavaScript 在单击缩略图时更改主图像。

我想要实现的目标

除了缩略图之外,我还希望当访问者从颜色属性下拉列表中选择颜色选项时,显示可用图像之一(基本上是与颜色选择相匹配)。

我看过的内容

我知道Ubercart Option Image,但是这个强制您为每个属性上传新图像,而不是每个产品。例如,属性颜色用于共享相同颜色的多种不同产品。

使用选项图像模块,所有共享相同属性的产品将显示相同的图像。所以这是不行的。

另外,我不想上传新图像,我希望能够使用产品节点中的现有图像之一。

Current Setup

Each product on the store has multiple images. When the visitor visits a product page they see a main image and a series of thumbnails (view). When they click on a thumbnail that image is instantly displayed in the main image area.

Each product also has an attribute selection dropdown for example "Colour".

Drupal / Ubercart Configuration

I'm using Drupal 6. There is a Product content-type that has a custom image field of type file. This image field accepts multiple values (i.e. multiple images).

I then use a view (views module) to display a series of thumbnails and javascript to change the main image when a thumbnail is clicked.

What I'm trying to achieve

What I would like in addition to the thumbnails is when the visitor selects a colour option from the colour attribute dropdown is for one of the available images be displayed (basically the one that matches the colour selection).

What I've looked at

I am aware of Ubercart Option Image but this forces you to upload a new image for each attribute and is not per product. For example the attribute colour is used for multiple different products that all share the same colours.

With option image module all products that share the same attribute would display the same image. So this is a no go.

Also I don't wan't to upload a new image I want to be able to use one of the existing images from the product node.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泪冰清 2024-09-19 07:56:58

这应该是可能的,但是是以一种迂回的方式。也许下面的方法值得你付出这样的痛苦?

  1. 创建新的内容类型。将其称为 ImagefieldAttribute。让该内容类型存储无限数量的图像字段。还将 ImagefieldAttribute 内容类型与称为属性的分类词汇相关联。本质上,ImagefieldAttribute 内容类型将存储具有相同属性的所有产品图像

  2. 现在在产品内容类型中创建一个节点引用字段。 nodereference 字段将仅链接到 ImagefieldAttribute 内容类型。 (编辑:确保节点引用字段可以具有无限数量的节点引用。这样您就可以引用任意数量的 ImageFieldAttribute 内容类型 - 每个内容类型都包含具有特定属性的所有图像)

  3. 您将需要更改视图和缩略图以反映产品内容类型中的额外间接级别。如果您在视图方面有经验,您就会认识到这是创建视图关系的情况。

  4. 您还应该能够创建公开的过滤器。请注意,您将再次需要使用关系,因为过滤器位于 ImagefieldAttribute 内容类型中(您将使用节点引用关系来获得该类型)。您可以限制将要显示的属性(例如,如果任何项目中没有黄色),则下拉列表中不应显示黄色。您可以通过使用 http://drupal.org/project/views_taxonomy_selective_filter 模块来实现此目的。

  5. 每次都必须创建一个 ImagefieldAttribute,然后将其节点引用到您的产品,这可能很乏味。使用 http://drupal.org/project/popups_reference

    可以轻松做到这

显然我还没有尝试一下,这样您可能会遇到不可预见的问题。不使用属性分类词汇表而仅使用 CCK 选择列表也可能是个好主意。但是,视图分类选择性过滤器随后将不起作用。

This should possible but in a somewhat roundabout way. Perhaps the following method will be worth the pain?

  1. Create a new content type. Call it ImagefieldAttribute. Let that content type store an unlimited number of imagefields. Also associate the ImagefieldAttribute content type with a taxonomy vocabulary called attribute. Essentially the ImagefieldAttribute content type will store all product images having the same attribute

  2. Now create a node reference field in the Product content type. The nodereference field will only link to the ImagefieldAttribute content type. (edit: make sure that nodereference field can have unlimited number of nodereferences. This is so that you can refer to an arbitrary number of ImageFieldAttribute content types -- each of them containing all images with a specific attribute)

  3. You will need to change the view and thumbnails to reflect an additional level of indirection in the Product content type. If you're experienced in views you'll just recognize this as a case of creating a views relationship.

  4. You should also be able to create exposed filters. Please note that again you will need to use relationships as the filters would be in the ImagefieldAttribute content type (which you will get through using the nodereference relationship). You can restrict the attributes which will be on display (e.g. If there is no yellow color amongst any of the items) you should not get yellow in the drop down. This you can achieve by using the http://drupal.org/project/views_taxonomy_selective_filter module.

  5. It can be tedious to have to create an ImagefieldAttribute everytime and then nodereference it to your Product. This can be made easy using http://drupal.org/project/popups_reference

Obviously I haven't tried this out so you could encounter unforeseen problems along the way. It might also be a good idea to not have a taxonomy vocabulary for attributes but simply CCK select list. However, the views taxonomy selective filter will not work subsequently.

守护在此方 2024-09-19 07:56:58

如果我明白你想要完成什么,我已经在 http://homespun- 做了类似的事情at-heart.com/product/gracie。我所做的就是简单地自定义 option_images 模块的 javascript 和预加载功能来更新主产品图像,而不是像默认情况下那样更新 option_image 的图像。

我所做的一个主要缺点是重复的图像存储在服务器上的两个位置,因此需要单独下载。这是一个小项目,是在预算范围内完成的,所以我没有自由地投入时间来“正确”地完成它。但是,如果这就是您所需要的……它就可以了!

在此站点上,我们不会将多个图像直接附加到产品上,而是使用选项图像模块将它们附加到属性上。编写一些 js 也不需要花费大量工作,以便在单击缩略图时更新颜色选择。

更新1:
我不确定你愿意在这个项目上投入多少,但当我更多地考虑这个问题时,在我看来你需要的是指定哪些属性选项适用于哪些图片。我想象的是,当您在产品上上传图像时,您将能够做出这些选择。

然后,当访问者选择附加到图像的选项或单击缩略图时,选项就会更新。

我还没有考虑足够长的时间来可视化界面。也许您的一些其他要求会决定这一点。

更新2:
在您发表以下评论后,这里有一些更多建议。

在产品的编辑/选项屏幕上,您可以有一个下拉菜单,允许您选择哪些图像适用于哪些特定选项。这将使您克服将图像多次上传到服务器的问题。

要实现这一点,需要大量的工作,并且可能需要另一个表或至少在 uc_product_options 表中添加一个字段来存储产品和图像之间的关系。我将使用 uc_option_image 模块作为起点。它将为您提供完成所需任务的很多指导。

为了克服将属性附加到多个产品的问题,我所做的就是让我的客户在属性上放置所有可能的颜色,然后他们只选择适用于特定产品的颜色。我们考虑过但否决的另一个选项是设置许多不同的属性,这些属性大致对应于每个不同的产品。我忘记了我们没有走这条路的所有原因,但其中一些原因非常明显。 :-)

If I understand what you are attempting to accomplish, I have done something similar at http://homespun-at-heart.com/product/gracie. What I did to accomplish this was simply customize the option_images module's javascript and preloading functionality to update the main product image instead of option_image's image like it does by default.

The one major drawback of what I did was that duplicate images are stored at two places on the server and therefore separately downloaded. This was a small project that was done on a budget so I didn't have the freedom to invest the time to do it "right". But, if that is all you need...it works!

On this site we aren't attaching more than one image directly to the product, instead they are attached to the attributes with the option images module. It also wouldn't take an awful lot of work to write some js so that the color selection would be update when the thumbnail is clicked.

Update 1:
I'm not sure how much you are willing to invest it this project, but as I have thought about this a little more, it seems to me what you need it is to specify which attribute options apply to which pictures. What I would visualize is that when you are uploading the images on the product you would be able to make these selections.

Then, when the visitor selects an option that is attached to an image or when a thumbnail is clicked, the options are updated.

I haven't thought about it long enough to visualize the interface yet. Maybe some of your other requirements would dictate that.

Update 2:
After your comment below, here are some more suggestions.

On the edit/options screen of you product, you could have a dropdown that would allow you to select which images apply to which of the specific options. This will allow you to overcome the issue of having your image uploaded to your server multiple times.

To accomplish this would require a substantial amount of work and probably another table or at least a field added to the uc_product_options table to store the relationship between the product and the image. I would use the uc_option_image module as a starting point. It would give you a lot of direction on accomplishing what is needed.

What I did to overcome the issue of having the attributes attached to multiple products is have my customer put all the possible colors on the attribute then they select only the ones apply to the specific product. The other option that we considered but vetoed was setting up a lot of different attributes that would roughly correspond to each different product. I forget all the reasons we didn't go this route but some of them are pretty obvious. :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文