commerce_product_reference.module uses wrapping HTML to assign a contextual class to product fields with multiple values, for use in automatically updating these fields' values when product attributes are chosen (i.e. changing an image when a color option is chosen, etc.)
Currently, a <span> is used, which can cause a few minor problems when styling Products (particularly, extra space is added below the field because of the span's line height). The single class name used node-[ID]-product-[field_name], while necessary for the ajax functionality, is far too specific for styling purposes.
The attached patch changes this wrapper to a <div> and adds two generic classes, product-field and [field_name].
Everything seems to be working fine with this change in my localhost.
Thanks!
Sheena
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | commerce.product_reference_classes_1280894_07.patch | 1.34 KB | rfay |
| better-formatting-product-reference-field-wrappers.patch | 1.23 KB | sheena_d |
Comments
Comment #1
fakingfantastic commentedI +1 this patch, it does the job, but there is still a bunch of HTML just to spit out an image. In one case, i got this...
I understand the bloat is the Field API, so there's not much to do there. But what about moving node-8.... to an ID ... since it's an ID :)
What are we all thinking?
Comment #2
sheena_d commentedI think moving node-8.... to an ID will require changes in the ajax functionality and it could also cause multiple IDs on a page if you happen to have a view of node teasers on the full node page. Although, I guess multiple IDs is a threat anytime you have node teasers on a full-node page.
Comment #3
rszrama commentedTagging.
Comment #4
Jeff Burnz commentedCouple of thoughts:
"product-field" - seems too generic to be useful.
"field-image" - should be name spaced, i.e. "product-field-image"
I'll test the patch out shortly.
Comment #5
rszrama commentedYeah, we can probably make that commerce-product-field to be more helpful. field-image is just the name of the field classified, so we can go with the Drupal syntax (field-name-field-image) if it's worth having in there twice. We could always try to combine it somehow w/ commerce-product-field, but that'd make for some ungainly classes. : P
Comment #6
Jeff Burnz commentedWell, the reason I would want those classes name spaced is so they are always unique and never duplicate what theme_field is giving us already - so better to have ungainly long classes that are reliable and usable. Duplicating theme_fields classes could spell bad news depending on the themes CSS.
Comment #7
rfayThis looks fine to me. Here's a slightly revised patch that tries to address the above comments.
I've tested this with the standard multiple-tshirt-attribute test and Bartik. Seemed fine.
Comment #8
rszrama commentedI had to duplicate the new classes in the AJAX refresh callback used for the Add to Cart form. I also switched product-field to commerce-product-field in line with what I think Jeff's comment #8 was indicating. Everything tests out fine for me, too.
Commit: http://drupalcode.org/project/commerce.git/commitdiff/3c58c5c
Comment #9
rszrama commentedBah, in my duplication of the new classes into the Cart module I accidentally removed the assignation of the replacement class to a standalone variable for use in the AJAX command. Fixed now.
Commit: http://drupalcode.org/project/commerce.git/commitdiff/95843b2
Comment #10
rszrama commented