2 replies [Last post]
tharemedy's picture
Offline
Joined: 04/23/2008
Juice: 35
Was this information Helpful?

Basically Ive added a field to the product node called mp3preview. Which holds html to display an flash mp3 player with the proper agruements. Now Ive tried extending the tables but ive only gotten it to display the column MP3PREVIEW. but the values are empty. take a look at the code

<code>
<?php
// $Id$

function ucproductfield_table_alter($table_id, $op) {
  if ($table_id == 'uc_product_table') {
    switch ($op) {
      case 'fields':
        $fields[] = array('name' => 'mp3preview', 'title' => t('Mp3 Preview'), 'weight' => 3, 'enabled' => TRUE);
        return $fields;

   case 'data':
      $result = db_query("SELECT field_mp3preview_value FROM {content_type_product}");
      while ($row = db_fetch_object($result)) {
        $data['mp3preview'][] = $row->mp3preview;
}

      return $data;

     
    }
  }
}

That is what I have in my module

and

http://www.queencitybeats.com/catalog/1/club_beats

this is what displays.

tharemedy's picture
Offline
Joined: 04/23/2008
Juice: 35
Re: displaying a custom field added to the product node

Am I posting in the right forum for this kind of thing?

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3424
Re: Re: displaying a custom field added to the product node

Check out http://www.ubercart.org/contrib/763 for a working example of using hook_table_alter. Just a guess, you might have to do a node_load in your data case to get the product fields completely loaded.

Another option would be to skip TAPIr entirely and do this with Views. It's easy to create a View to display additional CCK fields.

<tr>.