7 replies [Last post]
GoldenToque's picture
Offline
Joined: 11/22/2007
Juice: 3
Was this information Helpful?

Got my first ubercart site setup, and all went fairly smoothly. However now that it is configured, and I am wanting to customize it, has a tutorial / document page / forum post been written outlining how one can edit the default product page and or catalog pages, with regards to including or not including content that is spit out by default, as well as moving the layout around.

Thanks

d.

oslinux's picture
Offline
Joined: 09/06/2007
Juice: 461
Re: Product Node

what do you have in mind? In shop admin you can select and select what is to be shown for a product, like weight, prize, qty, etc. Then you can set up a theme for products that it all looks just as you want it to be ... Be more specific what you bear in mind !! Smiling

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Product Node

That kind of thing falls under the realm of "Themeing your Drupal site". There is a lot of material on drupal.org that you can read and study. Products are a type of node, so you want to look for pages talking about themeing content, using tools like the Contemplate module or adding a template file to your theme with PHPTemplate.

Also search for "overwriting theme functions". This is the only way to customize the way the catalog pages look outside of the settings already available.

starkos's picture
Offline
Joined: 12/10/2007
Juice: 4
Where is the default template?

Forgive my ignorance - the Drupal themeing guides suggest copying the template out of the module and then modifying it...but I can't figure out which code represents the product template. Can anyone point me to a function or filename to help me get started? Many thanks!

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Where is the default template?

Nodes are a little funny in that regard. For PHPTemplate themes, which are most of them nowadays, there is a file in the theme folder called node.tpl.php. By default, that determines the markup for all the parts of a node except for the content. It just accepts whatever has been generated by the node module and inserts it in the right spot. The content is generally created with hook_view(). For product type nodes, this is uc_product_view(). In addition, other modules can use hook_nodeapi() to change the content of nodes before the theme gets to it.

Fortunately, all of the pieces of the node object that go into $node->content are available to the node template file, so you can modify it to rearrange the various parts of the content.

incaic's picture
Offline
Joined: 10/13/2007
Juice: 115
Re: Product Node

I don't know whether this is a better or worse way.
(maybe someone more experienced can comment with pros & cons)

I created the following function and modify everything I want inside.
I like this because all my modifications are in 1 place and do not
clutter my hook_nodeapi().

<?php
function <mytheme>_product_node_form($form) {
 
//modify $form here
 
$form['base']['prices']['#theme'] = '<mytheme_product_form_prices';
  echo
'<pre>';    // debug only
 
print_r($form);  // debug only
 
echo '</pre>';   // debug only
 
return drupal_render($form);
}
?>

I also changed the way theming was done for certain sections.
The simple example I'm using is the prices section of the product form.
So, the new theme function would be:

<?php
function theme_<mytheme>_product_form_prices($prices) {
  return
'<table><tr><td>'."\n".drupal_render($prices['cost'])
    .
'</td><td>'.drupal_render($prices['sell_price'])
    .
'</td></tr></table>'."\n";
}
?>

e.

psynaptic's picture
Offline
Early adopter... addicted to alphas.Not KulvikTheminator
Joined: 08/28/2007
Juice: 731
If you have devel module

If you have devel module installed you can simplify this:

<?php
 
echo '<pre>';    // debug only
 
print_r($form);  // debug only
 
echo '</pre>';   // debug only
?>

to this:

<?php
  dpr
($form);
?>

might just save you a few keystrokes here and there.

eugef@drupal.org's picture
Offline
Joined: 12/24/2007
Juice: 102
Re: If you have devel module

How can i theme product list on catalog and manufacturer pages?