function template_preprocess_amazon_gallery in Amazon Product Advertisement API 7.2
The template_preprocess_amazon_gallery handles the "Amazon Gallery Block". The Amazon Gallery Block is rended on the Amazon Product Node Type and Amazon Store Module paths Galleries reference the Product ASIN # stored in the URL path
Node: Amazon Product Pathauto: product/[node:field_product_asin]/[node:nid]
Module: Amazon Store Pathauto: variable_get('amazon_store_path')/[node:field_product_asin]/[node:nid]
File
- amazon_component/
amazon_component.preprocess.inc, line 135
Code
function template_preprocess_amazon_gallery(&$variables) {
// Explode :: Convert current page alias into array
$currentAlias = explode('/', drupal_get_path_alias());
//$message = amazon_component_item_lookup($currentAlias[1]);
// IF :: the block is being rendered on Amazon Product Node type or Amazon Store Module path proceed.
// It's assumed the first URL seperator is "product" or the Amazon Store Path (default "store")
// and the second position is an Amazon Product ASIN.
// Depending on future Open Source releases we may switch it to scan the URL array for an ASIN in any position.
if ($currentAlias[0] == 'product' || $currentAlias[0] == variable_get('amazon_store_path')) {
$result = amazon_component_gallery_lookup($currentAlias[1]);
// Create gallery variables: $smallimagegallery, $mediumimagegallery, etc.
foreach ($result as $item) {
foreach ($item as $gallery) {
foreach ($gallery as $image) {
foreach ($image as $imageData) {
$variables[$imageData['size']][$imageData['image_order']] = theme('image', array(
'path' => $imageData['url'],
'attributes' => array(
'height' => $imageData['height'],
'width' => $imageData['width'],
),
'getsize' => FALSE,
));
unset($image['asin']);
}
// foreach
}
// foreach
}
// foreach
}
// foreach
}
// endif
// Required $variables arrays;
$variables['classes_array'] = array();
$variables['attributes_array'] = array();
$variables['title_attributes_array'] = array();
$variables['content_attributes_array'] = array();
}