In the past, all product class items had a "node-type-product" class assigned to their body tag, even if it wasn't the standard "Product" node type. I just noticed this is no longer the case, so now we have numerous product pages that aren't styled correctly. Was this recently changed? I usually read all the release notes before upgrading, but don't recall seeing anything about this.

CommentFileSizeAuthor
#5 1448760-product-body-class.patch1.18 KBlongwave

Comments

tr’s picture

Hmm, pickaxe doesn't show me any results for 'node-type-product' anywhere in the Ubercart source code history. Specifically when in the past was this working for you? Perhaps you had a custom template for the product class that added this?

OldAccount’s picture

How does the "node-type-product" class get added to regular products?

Unfortunately I can't remember the last time it was working, but I specifically recall being appreciative of it because we have about 15 product classes and I was glad I wouldn't have to add them all to the CSS, I could just use "node-type-product".

I am using a custom product template (node--product.tpl.php) and it's still being picked up by the product class items, it's just the CSS body class that isn't.

longwave’s picture

template_preprocess_html() in core has the following code:

  // If on an individual node page, add the node type to body classes.
  if ($node = menu_get_object()) {
    $variables['classes_array'][] = drupal_html_class('node-type-' . $node->type);
  }

I guess we could add another preprocess function to add another body class for Ubercart products; I'd prefer not to reuse node-type-product but a separate class so themers can target the actual "product" type, or all products.

tr’s picture

Product classes use node--product.tpl.php because Ubercart implements uc_product_preprocess_node() to allow this. But if you ever do define a node--myclass.tpl.php for a "myclass" product type, this more specific template will take precedence.

longwave’s picture

Title: Product class items no longer have "node-type-product" CSS class » Add common CSS class to all product node pages
Version: 7.x-3.0-rc3 » 7.x-3.x-dev
Category: bug » feature
Status: Active » Needs review
StatusFileSize
new1.18 KB

Repurposed this as a feature request. The attached patch adds a "uc-product-node" class to the body tag of all product node pages, including a test to prove this.

longwave’s picture

Status: Needs review » Fixed

Committed #5

OldAccount’s picture

Perfect, thanks so much!

tr’s picture

If this worked "in the past" then you must have had some custom code to do it - #5 is a pure D7 solution, and is not something that was ever implemented in Ubercart.

Status: Fixed » Closed (fixed)

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