<?php
/******************************************************************************
* Module Functions *
******************************************************************************/
function uc_sm_help($path, $arg)
{
$output = '';
return $output;
}
function uc_sm_perm()
{
return array('access uc_sm content');
}
/**
* Returns the table header for the product view table.
*
* @see uc_sm_table()
*/
function uc_sm_tapir_table_header_alter() {
static $columns = array();
if (empty($columns)) {
$enabled = uc_product_field_enabled();
if (module_exists('imagecache') && $enabled['image']) {
$columns['image'] = array(
'weight' => -5,
'cell' => array('data' => t('Image')),
);
}
$columns['name'] = array(
'weight' => 0,
'cell' => array('data' => t('Name'), 'field' => 'n.title'),
);
/*ezt írtam bele */
$columns['garancia'] = array(
'weight' => 2,
'cell' => array('data' => t('warranty'), 'nowrap' => 'nowrap'),
);
/*ezt írtam bele */
if ($enabled['list_price']) {
$columns['list_price'] = array(
'weight' => 3,
'cell' => array('data' => t('List price'), 'field' => 'p.list_price'),
);
}
if ($enabled['sell_price']) {
$columns['price'] = array(
'weight' => 5,
'cell' => array('data' => t('Price'), 'field' => 'p.sell_price'),
);
}
if (module_exists('uc_cart') && (arg(0) != 'admin' || $_GET['q'] == 'admin/store/settings/tables/uc_product_table') && $enabled['add_to_cart']) {
$columns['add_to_cart'] = array(
'weight' => 10,
'cell' => array('data' => variable_get('uc_teaser_add_to_cart_text', t('Add to cart')), 'nowrap' => 'nowrap'),
);
}
drupal_alter('tapir_table_header', $columns, 'uc_product_table');
}
return $columns;
}
/**
* Displays product fields in a TAPIr table.
*
* Displays image, name, price, and add to cart form.
*/
function uc_sm_tapir_table_alter($args = array()) {
$enabled = uc_product_field_enabled();
$table = array(
'#type' => 'tapir_table',
'#attributes' => array(
'class' => 'category-products',
),
'#columns' => uc_product_table_header(),
'#rows' => array(),
);
$context = array(
'revision' => 'themed',
'type' => 'product',
'class' => array('product'),
);
$options = array('label' => FALSE);
foreach ($args as $nid) {
$data = array();
$node = node_load($nid);
if ($enabled['image']) {
if (module_exists('imagecache')) {
if (($field = variable_get('uc_image_'. $node->type, '')) && isset($node->$field) && file_exists($node->{$field}[0]['filepath'])) {
$image = $node->{$field}[0];
$data['image'] = array('#value' => l(theme('imagecache', 'product_list', $image['filepath'], $image['alt'], $image['title']), 'node/'. $node->nid, array('html' => TRUE)));
}
else {
$data['image'] = array('#value' => t('n/a'));
}
}
}
$data['name'] = array(
'#value' => l($node->title, 'node/'. $node->nid),
'#cell_attributes' => array('width' => '100%'),
);
/*ezt írtam bele */
$data['garancia'] = array('#value' => $node->field_garancia[0]['value'], '#cell_attributes' => array('width' => '100%'),
);
/*ezt írtam bele */
$context['subject'] = array('node' => $node);
if ($enabled['list_price']) {
$context['class'][1] = 'list';
$context['field'] = 'list_price';
$data['list_price'] = array('#value' => uc_price($node->list_price, $context, $options), '#cell_attributes' => array('nowrap' => 'nowrap'));
}
if ($enabled['sell_price']) {
$context['class'][1] = 'sell';
$context['field'] = 'sell_price';
$data['price'] = array('#value' => uc_price($node->sell_price, $context, $options), '#cell_attributes' => array('nowrap' => 'nowrap'));
}
if (module_exists('uc_cart') && arg(0) != 'admin' && $enabled['add_to_cart']) {
$data['add_to_cart'] = array('#value' => drupal_get_form('uc_catalog_buy_it_now_form_'. $node->nid, $node));
}
$table[] = $data;
}
if (!count(element_children($table))) {
$table[] = array(
'name' => array(
'#value' => t('No products available.'),
'#cell_attributes' => array(
'colspan' => 'full',
),
),
);
}
return $table;
}
?>
Bocsánat a hosszú kódért.
Szóval mi lehet az oka, hogy nem jelenik meg a katalógusomban a garancia cck mező értéke (de még a fejléc sem)?