Hi,
you have missed undocumented third parametr of the hook_table_alter. This parameter is an array of arguments somehow needed to extend the table.
Example: Extending uc_product_table with two columns from custom table
print_r($args) of the uc_product_table arguments:
Array
(
[nids] => Array
(
[0] => 304
[1] => 641
[2] => 454
[3] => 622
[4] => 391
...
[48] => 435
[49] => 633
)
[attributes] => Array
(
[class] => product-list
)
)In this case I can load additional data by parsing 'nids' array:
<?php
function evidence_table_alter($table_id, $op, $args) {
if ($table_id == 'uc_product_table') {
switch ($op) {
case 'fields':
$fields[] = array('name' => 'evidence',
'title' => t('Evidence'),
'weight' => 3,
'enabled' => TRUE);
$fields[] = array('name' => 'sold',
'title' => t('Sold'),
'weight' => 3,
'enabled' => TRUE);
return $fields;
case 'data':
foreach ($args['nids'] as $key => $nid) {
$r = db_fetch_array(db_query("SELECT eid,sold FROM {evidence} WHERE nid = %d",$nid));
$data['evidence'][] = $r['eid'];
$data['sold'][] = ( $r['sold'] === '0' ) ? t('Available') : t('Sold');
}
return $data;
}
}
}
?>This tapir feature is not well documented, I learn it by code research. I hope it helps someone.
Happy ÜberDrupaling 



Joined: 09/12/2007