I would like to add a small item thumbnail to the "similar items list" generated by the item details page.

Since this list creates a link using the "title" and the "ASIN" for each item. My question is; is it posible to add an item thumbnail link as well?

I know that with the "Amazon Filter" module this can be one from the editor area using the [amazon ASIN smallimage] format as an example.

Since the "similar items list" is a for-loop printing ASIN's and Titles, I was wondering if there a way to invoque the filter from within the template to append the image thumbnails with links to that list.

Any suggestions are most welcome.
Thanks,
Sandro.

Comments

TamboWeb’s picture

Title: Is is possibleto create thumbnails for "similar items list"? » Is it possible to create thumbnails for "similar items list"?
TamboWeb’s picture

Status: Active » Closed (fixed)

Never mind, I figured it out over the weekend.

rfay’s picture

Status: Closed (fixed) » Fixed

It's always nice to the next person with this question for you to explain how you "figured it out". They'll find this issue with a search... and then wonder what happened. Could you please explain what you did?

TamboWeb’s picture

You are right rfay.... Here is what I did to get the similar items thumbnails. The following is by no means the most elegant or efficient way to do this but it helped me understand the amazon module(s) so that I can create a helper module for my application.

My setup>
Drupal 6
Moudules: Amazon Module, Amazon Filter, Amazon Import, Amazon Store ( all enabled )

Copied the amazon_store_similar_items_panel.tpl.php from the amazon_store module directory to mytheme directory.

Changed the code that generates the list of similar items in the amazon_store_similar_items_panel.tpl.php template file

Look for this code:

if ($item->SimilarProducts->SimilarProduct): ?>
<div class="SimilarProducts" >
<ul>
<?php foreach ($item->SimilarProducts->SimilarProduct as $sim): ?>
	<li><a rel="nofollow" href="<?php print url(AMAZON_STORE_PATH ."/item/{$sim->ASIN}") ?>"><?php print $sim->Title ?></a></li>
<?php endforeach; ?>
</ul>

Now here is what change:

<?php foreach ($item->SimilarProducts->SimilarProduct as $sim): ?>


<?php //This code uses the amazon filter to get the similar items thumbnails.
	//We loop through the $sim array, 
	//We build an amazon filter tag using the $sim->ASIN.
	// We pass the string through the amazon filter.
	// The filter module then does a db look-up if no item is found  for such ASIN it does a web lookup.
	// Once the item is retreived either from the db or the web, we update the db and get the image url.
	// We build the image markup with some massaging.

	$sim_image_url = '[amazon '.$sim->ASIN.' smallimage]'; 
	$sim_image_url_mrkup = check_markup($sim_image_url, $node->format, false);
	$clean_sim_image_url = str_replace("<p>", "", $sim_image_url_mrkup);
	$clean_sim_image_url = str_replace("</p>", "", $sim_image_url_mrkup);

?>
	// We output the LI element with the tumbnail as a link.
	<li><a rel="nofollow" href="<?php print url(AMAZON_STORE_PATH ."/item/{$sim->ASIN}") ?>"><?php print $clean_sim_image_url;?>	-   <?php print $sim->Title ?></a></li>
<?php endforeach; ?>

For the above to work, the amazon filter must be enabled and set for the apropriate input format.

Potential issues:
Every time we pass the $sim_image_url string through the check_markup() function, we do a db or web lookup and add amazon items to the database. ( your database will grow very quickly )

Other comments:
Although this may work, it does not seem to be the best implementation. A separate custom module with additional functionality to filter and narrow down the similar items may be a better implementation.

Hope this helps :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.