4 replies [Last post]
gmlussi's picture
Offline
Joined: 05/23/2011
Juice: 10
Was this information Helpful?

I've been desperately trying to work out how to modify the look of the individual Product pages to suit my needs in Drupal 7, with no luck due to the depressing lack of any documentation for the new version of Ubercart (I know it's technically in beta, but even so..)

I've managed to use the included views to change the look of the catalog pages, but there's seemingly no view for Product nodes.

I did figure out that by using the file node--product.tpl.php in my theme I can override the default. But I haven't been able to find out what the variables for things such as product images or description are, so I can't do ANYthing with this method.

I'd appreciate any and all help on this, so if anybody knows how to modify the node--product.tpl.php successfully, or how to use views for it instead, or any other way of customising it, I'd be very grateful.

Thanks.

end user's picture
Offline
Joined: 01/11/2008
Juice: 1728
Re: How can I theme the product pages on Drupal 7 and Ubercart 3

Some info for you here http://bri-space.com/content/template-suggestions-drupal-7-themehooksugg...

Then I'd install the contemplate module http://drupal.org/project/contemplate and under admin/structure/types/manage/page/template expand the body field and click Affect body output and then expand the Body Variables and then you can click on the variable links to print them out into the body field. I don't use contemplate itself to modify the node template but use the variables in my node--product.tpl.php

dantje's picture
Offline
Joined: 06/10/2011
Juice: 6
override with content machine name

Hi,
It is working for me. All I did was to copy an original node.tpl.php file, and then to rename it to node--product.tpl.php.
You can then find all the variables inside with <?php print_r($content); ?>
For a clearer view of the keys in $content array, use <?php print_r(array_keys($content));?>

Then, if you want to game with the variables, you can use drupal7's new theming functions.
If I want to hide the images for instance, then I would write: <?php hide($content['uc_product_image']);?>, before rendering the whole page at: <?php print render($content);?>

Anyway, I think a better practice for this method would be to override using the machine name of the classes you create with Ubercart.:
node--[machine-name-of-the-class-you-created-with-ubercart].tpl.php

useful_idiot's picture
Offline
Joined: 11/18/2011
Juice: 3
Implementing these variables?

I hate to ask you specifically, but you seem like you know what you are talking about. So I did a

<?php
print_r
(array_keys($content));
?>

.

It produced me this list of variables:

Array ( [0] => uc_product_image [1] => links [2] => comments [3] => display_price [4] => body [5] => dimensions [6] => model [7] => taxonomy_catalog [8] => add_to_cart [9] => list_price [10] => cost [11] => sell_price [12] => weight )

Is there anyway you could show me an example on how to get these to print individually on my node--product.tpl.php.

Eg - How to get the add to cart button to print? Or the name of the taxonomy term?

I am just unsure how to create the correct string to use.

Any help is greatly appreciated!!!

dantje's picture
Offline
Joined: 06/10/2011
Juice: 6
Printing variables

Hi,
For the add to cart button you should do:

<?php hide($content['add_to_cart']);?>

to hide it first.
Then you should to

<?php show($content['add_to_cart']);?>

to show it again on the page (or replace 'show' with 'render', I think it's the same)