The default product node output looks like this (+ indicates collapsed blocks, - indicates expanded blocks, like in Firebug):

- <div class="content">
  + <div class="product-image">
  + <div class="product-info product display">
  + <div class="product-info model">
    <p>
    this is the body of the product node
    <br/>
    "Filtered HTML" filter adds paragraph and line break tags
    </p>
    <p>no containing div for the body though ...</p>
  + <div class="product-info product sell">
  + <div class="add-to-cart">
  </div>

If the $node->body were wrapped in a <div></div>, CSS could be used to rearrange and style each of the blocks inside .content separately. For example, to move the image to the left and the text to the right, or simply apply a smaller font to the body text. As it stands, the body is not in a container so there's no CSS selector which will address all the body contents.

There's a short discussion of this issue at http://www.ubercart.org/forum/theming_and_design/11172/3_column_layout_n...

The attached patch defines a new theme function, theme_uc_product_body(), which is invoked from uc_product_view(). This has two positive effects: 1) Product bodies are now enclosed in a div, allowing CSS to affect the body contents, and 2) Providing a theme function means that users can override the function if necessary to modify the markup, without having to resort to writing a node-product.tpl.php.

After the patch, the above output looks like this:

- <div class="content">
  + <div class="product-image">
  + <div class="product-info product display">
  + <div class="product-info model">
  + <div class="product-body">
  + <div class="product-info product sell">
  + <div class="add-to-cart">
  </div>
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Island Usurper’s picture

FileSize
2.35 KB

That's a good idea, but I don't think node_teaser() should be used like that. node_teaser() is used when the node is saved, and the teaser is saved separately in the database. In addition, by the time uc_product_view() is called, the special <!--break--> teaser separator has been removed from $node->body, so you can't regenerate the teaser again in all cases. But that's alright because either $node->teaser or $node->body is available in uc_product_view().

This patch reassigns $node->content['body'] to the output of the new theme function, and also fixes uc_product_theme() to declare all of the arguments available to the theme functions.

TR’s picture

Yes, you're right about node_teaser() and the <!--break-->. I tried your version of the patch and it works for me.

Island Usurper’s picture

Status: Needs review » Fixed

Good deal. Committed.

Status: Fixed » Closed (fixed)
Issue tags: -Ubercart theme layer

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