Match ubercart default with node-product.tpl.php

Posts: 9
Joined: 01/25/2008

Does anyone have a version of the node-product.tpl.php file that will create an output that is exactly like the default ubercart product page style. I am trying to modify the default slightly but I do not want to totally redesign it yet. Smiling

Thanks

Posts: 5
Joined: 08/12/2008

Is any chance to get one?
I've found different solutions on this page but looking for the default one.

Posts: 133
Joined: 04/05/2008
Bug Finder

I'm interested in this.

Also, anything related to the Product List (on Catalog) because i want to change small things on the product grid.

Posts: 107
Joined: 05/28/2008

I would also be very interested in this!

Posts: 48
Joined: 11/29/2007
Bug Finder

Yeah i agree, would be really handy to have the default layout as a tpl.php file to fiddle around with.

The nifty products page is really good, i just used the code from about half way down the thread and it works very well.

m

Posts: 133
Joined: 04/05/2008
Bug Finder

As a non-themer I find it highly difficult to change the product page without some pointers.

Is it too hard for the devs to come up with the file requested by the original poster?

Posts: 132
Joined: 01/25/2008
Bug FinderBrain Stormer

This might not be exactly what you are looking for, but the best I can do at the moment. Here is an example of the Node-product-tlp.php file.

<!-- start node-product-page.tpl.php -->
<div id="node-<?php print $node->type; ?>" class="node clear-block">

  <div class="content">
    <?php if($node->content['image']['#printed']): ?>
      <?php print $node->content['image']['#value']; ?>
    <?php endif; ?>
    <div id="content-body">
      <h1 class="title"><?php print $title; ?></h1>
      <?php print $node->content['body']['#value']; ?>
    </div>
  </div>
 
  <?php print $node->content['add_to_cart']['#value']; ?>

  <div id="product-info">
    <h2 class="title">
      Product Information
    </h2>
    <?php
     
unset($node->content['body']);
      unset(
$node->content['image']);
      unset(
$node->content['display_price']);
      unset(
$node->content['add_to_cart']);
      unset(
$node->content['#children']);

      foreach(
$node->content as $key => $field) {
        if(
$field['#printed']) {
          print
'<div class="product-field">'. $field['#value'] .'</div>';
        }
      } 
   
?>

  </div>

  <?php if ($links): ?>
  <div class="links">
    <?php print $links; ?>
  </div>
  <?php endif; ?>

</div>

Posts: 48
Joined: 11/29/2007
Bug Finder

I think you can use 'content template' (contemplate) drupal module to spit out a template file, then you can cut n paste that into a new node-product.tpl.php file.

Or i might be completely wrong Smiling

m

Posts: 133
Joined: 04/05/2008
Bug Finder

thill wrote:
This might not be exactly what you are looking for, but the best I can do at the moment. Here is an example of the Node-product-tlp.php file.

<!-- start node-product-page.tpl.php -->
<div id="node-<?php print $node->type; ?>" class="node clear-block">

blablabla...

</div>

Hey thill!

It's quite there! Are you willing to give it another try?

I'm posting differences between the "default one" and yours, using the Garland Theme

Default look, unchanged:
http://files.uploadbag.com/Files/Public/b888aaac_png_d5abb516__productpa...

Thil's look, with a custom node-productpage.tpl.php:
http://files.uploadbag.com/Files/Public/a3788376_png_41639625__productpa...

As you can see, the second screenshot doesnt show the Category terms, among other small differences.

Posts: 132
Joined: 01/25/2008
Bug FinderBrain Stormer

I am sorry if I misled you, I wasn't saying that code was the exact code, it was just a custom one I have used for a site. I was just trying to give you something to work with to make it to your liking.

Posts: 133
Joined: 04/05/2008
Bug Finder

I understand thil.

Believe me, i've been trying to achieve what i want but with no success.
I have decided to go with a simple look, basically the same as the "default one" .

The only thing i need to add is Lightbox support. And for that sole reason i have to change the template/theme.

As i do this, the images popup with Lightbox but the thumbnails are aligned on the left side of the screen but i want them on the right hand side (just like the default way)!

Do you know how could i achieve this?

Here's my full template code (it's different from yours):

<!-- lightbox is working, but thumbs are on the left side of the page-->

<?php // Grabs the firsts image path and sets $imagePath.
$imagePath = $node->field_image_cache['0']['filepath'];
?>


<div id="node">

<?php // product title  ?>
<h2><?php print $title ?></h2>

<?php // product description  ?>
<?php print $node->content['body']['#value'];  ?>

<?php  // list price and sell price display  ?>
<div id="price">
<p>List Price: <?php print uc_currency_format($node->list_price); ?></p>
<p>Sell Price: <?php print uc_currency_format($node->sell_price); ?></p>
</div>

<?php // default image display  ?>
<?php $imagePath = $node->field_image_cache['0']['filepath']; ?>
<a href="<?=base_path()?><?=$imagePath?>" rel="lightbox[prod]"><img src="<?=base_path()?>files/imagecache/product/<?=$imagePath?>" alt="<?=$title?>" title="<?=$title?>"></a>

<?php // all image display  ?>
<ul class="other_imgs">
<?php foreach ($node->field_image_cache as $images) { if ($images['filepath'] != $imagePath) { ?>
   <a href="<?=base_path()?><?=$images['filepath']?>" rel="lightbox[prod]" title="<?=$title?>">
   <img src="<?=base_path()?>files/imagecache/uc_thumbnail/<?=$images['filename']?>" alt="<?=$title?>"></a>
    <?php } } ?>
</ul>

<div id="cartButtons">
<?php // add to cart buttons ?>
<?php print $node->content['add_to_cart']["#value"]; ?>
</div>

</div>

Here's a screenshot to make it easier: http://files.uploadbag.com/Files/Public/57016b57_png_1f1d9734__pleasemak...

Posts: 133
Joined: 04/05/2008
Bug Finder

Ok, its working better now (still far from perfect).

The code for the image part to be aligned on the right should include the proper classes, like this:

<div class="product_image">
<?php // default image display  ?>
<?php $imagePath = $node->field_image_cache['0']['filepath']; ?>
<a href="<?=base_path()?><?=$imagePath?>" rel="lightbox[prod]"><img src="<?=base_path()?>files/imagecache/product/<?=$imagePath?>" alt="<?=$title?>" title="<?=$title?>" class="imagecache imagecache-product"></a>

<?php // all image display  ?>
<ul class="other_imgs">
<?php foreach ($node->field_image_cache as $images) { if ($images['filepath'] != $imagePath) { ?>
   <a href="<?=base_path()?><?=$images['filepath']?>" rel="lightbox[prod]" title="<?=$title?>">
   <img src="<?=base_path()?>files/imagecache/uc_thumbnail/<?=$images['filename']?>" alt="<?=$title?>" class="imagecache imagecache-uc_thumbnail"></a>
    <?php } } ?>
</ul>
</div>

Posts: 133
Joined: 04/05/2008
Bug Finder

Hello,

I've worked on these things and i'm posting a new file that can be used to achieve the "default look".

It's very easy to edit and add other fields, etc, and still keep the way it looks.

This also has builtin Lightbox support. If you dont use it (why not?), you will probably have to change that part.

<!--
Doomed's own ubercart product template: this one should look very similar to the 'default look'.
It has only few selected fields and comes with Lightbox support.
Created with the help of many people on the forums of Ubercart.org .
Last update: 21/nov/2008
-->

<?php // Grabs the firsts image path and sets $imagePath.
$imagePath = $node->field_image_cache['0']['filepath'];
?>


<!-- node and node inner -->
<div class="node <?php print $node_classes ?>" id="node-<?php print $node->nid; ?>">
<div class="node-inner">


<!-- show categories, etc. -->
<?php if ($unpublished || $submitted || count($taxonomy)): ?>
<div class="node-top">
  <?php if ($unpublished) : ?>
    <div class="unpublished"><?php print t('Unpublished'); ?></div>
  <?php endif; ?>

  <?php if ($submitted): ?>
    <div class="submitted">
      <?php print $submitted; ?>
    </div>
  <?php endif; ?> 
 
  <?php if (count($taxonomy)): ?>
    <div class="taxonomy"><?php print t(' Categorias: ') . $terms; ?></div>
  <?php endif; ?>
</div>
<?php endif; ?>
<!-- /show categories, etc. -->


<!--show default image first, then others-->
<div class="product_image">
<?php $imagePath = $node->field_image_cache['0']['filepath']; ?>

<?php if (!$node->field_image_cache == NULL) { ?>
<a href="<?=base_path()?><?=$imagePath?>" rel="lightbox[prod]">
<img src="<?=base_path()?>files/imagecache/product/<?=$imagePath?>" alt="<?=$title?>" title="<?=$title?>" class="imagecache imagecache-product">
</a>
<?php } ?>

<?php if (count($node->field_image_cache) > 1) { ?>
<ul class="other_imgs" style="list-style-type:none; margin-top:10px; text-align:center;">
<?php foreach ($node->field_image_cache as $images) { if ($images['filepath'] != $imagePath) { ?>
   <li style="display:inline; padding:0; margin-left:0;">
     <a href="<?=base_path()?><?=$images['filepath']?>" rel="lightbox[prod]" title="<?=$title?>">
     <img src="<?=base_path()?>files/imagecache/uc_thumbnail/<?=$images['filename']?>" alt="<?=$title?>" class="imagecache imagecache-uc_thumbnail">
     </a>
   </li>
<?php } } ?>
</ul>
<?php } ?>
</div>
<!--/show default image first, then others-->


<!--show fields: sku, description, prices-->
<?php //print $title ?>
<div class="model"><?php print $node->model ?></div>
<p><?php print $node->content['body']['#value'];  ?></p>
<div class="sell_price">Preço: <?php print uc_currency_format($node->sell_price); ?></div>
<div class="display_price"><?php print uc_currency_format($node->sell_price); ?></div>
<!--/show fields: sku, description, prices-->


<!--show add to cart button-->
<div class="add_to_cart">
<?php print $node->content['add_to_cart']["#value"]; ?>
</div>
<!--/show add to cart button-->

<!--wish i knew-->
  <?php if ($links): ?>
    <div class="links">
      <?php print $links; ?>
    </div>
  <?php endif; ?>
<!--/wish i knew-->

</div>
</div>
<!-- /node and node inner -->

It's working pretty well atm.

Use it and post feedback/improvements - i'm specially interested in removing redundant/unnecessary stuff.

AttachmentSize
node-productdoomed.tpl_.php_.txt2.9 KB
Posts: 132
Joined: 01/25/2008
Bug FinderBrain Stormer

Why would you use lightbox and not the built in thickbox support? Is it that much better?