can i display help text between attribute selects?

Posts: 95
Joined: 08/07/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Spreading the word - Ubercart for president.

This is G o o g l e's cache of http://www.ubercart.org/forum/support/1414/can_i_display_help_text_betwe... as retrieved on Aug 1, 2007 20:03:12 GMT.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
This cached page may reference images which are no longer available. Click here for the cached text only.
To link to or bookmark this page, use the following url: http://www.google.com/search?q=cache:SbNKzbLcB9wJ:www.ubercart.org/forum...

Google is neither affiliated with the authors of this page nor responsible for its content.
These search terms have been highlighted: 07 24 2007
Ubercart

* Home
* Documentation
* Forums
* Issues
* Livetest

Home » Forums » Ubercart » Support
can i display help text between attribute selects?
Submitted by megg on Sun, 07/15/2007 - 12:08
megg
Posts: 18
Joined: 06/08/2007

hi everyone Smiling

i'd like to display some help text (in a collapsible block, for example) for each product attribute. something like this:

----------------------

Price: €30.00

Size:
[large, +€5.00]

why are some sizes more expensive than others?

Colour:
[pink]

why are some colours uglier than others?

[Add to cart]

----------------------

if i take a little peek in node-product.tpl.php, i see that the ordering functionality is all spat out with a $content variable.

anyone have any idea how i might be able to get inside $content and add my blocks and text without mangling anything? or perhaps point me in the direction of a good tutorial? teach a woman to fish, and all that...

* Add new comment

permalinkMon, 07/16/2007 - 06:25
_Troy_@drupal.org

Posts: 19
Joined: 04/19/2007
Bug FinderBug Killer

Go deeper and use

<?php
echo $node->content['sell_price']['#value']
?>

<?php
echo $node->content['add_to_cart']['#value']
?>

in the order you want. Don't use <? echo $content ?>, echo each field manually.

* reply

permalinkMon, 07/16/2007 - 07:45
Ryan

Posts: 1669
Joined: 09/26/2006
AdministratorCode Monkey Head - I eat bugs.

Also, I'm not sure if this is what you're referring to or not, but...

On several of the sites I've developed, I've kept a custom module that I drop code into as I need it. I usually just call it the name of the site, like coa.module for Congress of Adam (not responsible for the theme). If you know PHP and can get a basic handle on the Drupal API, this will become very handy for you.

In your case, you could end up using Drupal's hook_form_alter() to add help text to the form directly. In the Drupal Forms API, you can add a #description value to any form element to show the help text beneath it... this is used all over the place in the menus, but it is that smaller, gray text.

This is different from Troy's solution b/c you'd actually end up adding the info to the form directly instead of just on the page... which may have the undesirable side effect of putting the text in the wrong places. But you can always add more specificity to the code that adds the text to tell it when to do it..

* reply

permalinkMon, 07/16/2007 - 15:34
megg
Posts: 18
Joined: 06/08/2007

thanks for the replies, guys.

i think the first suggestion to use is almost there, although i need to somehow get deeper into $node->content['add_to_cart']['#value'], because this outputs the add to cart button _and_ all attributes. i want to get stuff between the attribute selects, so i need something like $node->content['attribute_1']['#value']...

so i think i'm going to look into hook_form_alter() as suggested above, to see if that works and report back! wish me luck...

Smiling

* reply

permalinkMon, 07/23/2007 - 18:47
Phoenix0783
Posts: 9
Joined: 07/17/2007

I am going to try this myself, what file should I put the hook_form_alter function in? I was thinking of using fields that are added in content type, but not displaying them and then using the hook function to to display them where I want, instead of at the top, before the attributes.

* reply

permalinkTue, 07/24/2007 - 07:52
Ryan

Posts: 1669
Joined: 09/26/2006
AdministratorCode Monkey Head - I eat bugs.

I think I'll make a developer's guide page about this, but the best thing to do is to make a new module and maybe name it for your site. So if my site was Ryan's Rabbits, I might make a new module call rabbits.module. Then I would put my site specific functions, like rabbits_form_alter() in there to make the minor tweaks and improvements I need for that site. You don't want to just add it into an existing Ubercart file, because you'd lose it the next time you upgraded.

* reply

permalinkTue, 07/24/2007 - 11:56
Phoenix0783
Posts: 9
Joined: 07/17/2007

OK, thanks. I've been messing around with views but I don't think it will work because when I removed the body of the node most of the stuff on the page disappeared. So i guess the attributes are more integrated with the body of the product than i thought???

* reply

permalinkTue, 07/24/2007 - 13:47
Lyle

Posts: 567
Joined: 09/26/2006
AdministratoreLiTe!

The add to cart form, which is where the attributes are inserted by uc_attribute_form_alter(), is put into the $node->content array by uc_product_view() when not in teaser mode. If you can put PHP code into a view, you can do the same thing with

<?php
  theme
('uc_product_add_to_cart', $node);
?>

I've never used or even looked at Views, so I have no clue if that's possible.

* reply

permalinkThu, 07/26/2007 - 01:30
megg
Posts: 18
Joined: 06/08/2007

that's interesting... i did try some stuff with this but eventually gave up and decided to focus on more urgent details. but i'll be giving it another try, so will definitely let you all know if i get anything working. good to see i'm not alone in trying this! Smiling

* reply

--