function views_handler_field_amazon_participant::pre_render in Amazon Product Advertisement API 7.2
Same name and namespace in other branches
- 6 includes/views_handler_field_amazon_participant.inc \views_handler_field_amazon_participant::pre_render()
- 7 includes/views_handler_field_amazon_participant.inc \views_handler_field_amazon_participant::pre_render()
Run before any fields are rendered.
This gives the handlers some time to set up before any handler has been rendered.
Parameters
array $values: An array of all objects returned from the query.
Overrides views_handler_field::pre_render
File
- includes/
views_handler_field_amazon_participant.inc, line 40
Class
Code
function pre_render(&$values) {
$this->items = array();
$asins = array();
foreach ($values as $result) {
$asin = $this
->get_value($result, NULL, TRUE);
if (!empty($asin)) {
$asins[] = $asin;
}
}
if ($asins) {
$query = db_select('amazon_item_participant', 'aip')
->condition('asin', $asins, 'IN');
if ($this->options['participant_type'] != '**ALL**') {
$query = $query
->condition('type', $this->options['participant_type']);
}
$query
->fields('aip', array(
'participant',
'asin',
'type',
));
$results = $query
->execute();
while ($record = $results
->fetchAssoc()) {
$this->items[$record['asin']][] = array(
'participant' => check_plain($record['participant']),
'type' => check_plain($record['type']),
);
}
}
}