Added a handler for the third attribute
This commit is contained in:
@ -17,4 +17,5 @@ files[] = views/uc_views_handler_field_attributes.inc
|
||||
|
||||
files[] = views/uc_views_attribute_handler_field_order_product_attribute01.inc
|
||||
files[] = views/uc_views_attribute_handler_field_order_product_attribute02.inc
|
||||
files[] = views/uc_views_attribute_handler_field_order_product_attribute03.inc
|
||||
|
||||
|
@ -125,7 +125,20 @@ foreach($result as $row) {
|
||||
'handler' => 'uc_views_attribute_handler_field_order_product_attribute02',
|
||||
),
|
||||
);
|
||||
|
||||
// Add viewhandler for uc_order_product attributes: Attribute 03
|
||||
$data['uc_order_products']['attributes03'] = array(
|
||||
'title' => t('Product attribute 03'),
|
||||
'help' => t('The third attribute selection for the ordered product.'),
|
||||
'group' => t('Ubercart order product'),
|
||||
'field' => array(
|
||||
'table' => 'uc_order_products',
|
||||
'real field' => 'data',
|
||||
'handler' => 'uc_views_attribute_handler_field_order_product_attribute03',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Field handler to provide a human-readable version of the selected combination of attributes
|
||||
*/
|
||||
class uc_views_attribute_handler_field_order_product_attribute03 extends views_handler_field {
|
||||
|
||||
/**
|
||||
* Defines a few default options for the combination field
|
||||
*/
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
$data = unserialize($values->{$this->field_alias});
|
||||
$result = "";
|
||||
if (is_array($data['attributes'])) {
|
||||
$rows = array();
|
||||
foreach ($data['attributes'] as $attribute => $option) {
|
||||
$rows[] = t('@option', array('@attribute' => $attribute, '@option' => implode(', ', (array) $option)));
|
||||
if (count($rows)) {
|
||||
//Grab the value for the third attribute.
|
||||
$result = $rows[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user