Amazon Wishlist Plugin

[fa:p:a=blog-images,id=470525894,j=l,s=s,l=p]Chadd had asked me a while back for a birthday wishlist, I hadn’t responded back to him yet because I wanted to try to get my Amazon wishlist directly on my blog. And thanks to a slightly tweaked version of the Amazon Wishlist Plugin by Ryan Prins I am proud to present My Amazon Wishlist kindly formatted to match the rest of my site.

Slightly tweaked you ask? Well although this plugin does an awesome job of getting my amazon wishlist, it did it with pages and in a markup I found difficult to format. So I created a new function, which is mostly a clone of the original calling function but this version aggregates all the items onto a single page, and in a format I could more easily work with. I did however, ditch the use of images that the original function had.

Anyway, if your in the same boat as me, and want to get all of your wishlist items onto a single page, this may just be the function for you. All you have to do is append the following code directly before the closing ?> line in the amazon-wishlist.php file, and change the call in your wishlist page to this function. I’ve included the CSS as well. Enjoy.

/**
  * Print a single page with the entire wishlist for all eyes to see!
  */
  function displayPagelessAmazonWishlist() {
  global $listDetails, $imgSize;
  
  /* Get the complete, and formatted list of items */
  $niceItems = array();
  $listData = prepareAmazonWishlistItems(1); /* Initialize the data */
  for($i = 1; $i <= $listDetails['TOTALPAGES']; $i++) {
  $listData = prepareAmazonWishlistItems($i);
  foreach ($listData as $item) {
  $nice = prepareAmazonWishlistEntry($item);
  $niceItems[$nice['PRODUCTGROUP']][] = $nice;
  }
  }
  
  /*
  echo ‘<pre>’;
  print_r($niceItems);
  echo ‘</pre>’;
  */
  
  if(!empty($niceItems)) {
  
  foreach ($niceItems as $group) {
  
  $h3 = $group[0]['PRODUCTGROUP'];
  $output .= "<h3>$h3</h3>\n";
  
  foreach ($group as $item) {
  
  $dateAdded = date(’m/d’, strtotime($item['DATEADDED']));
  /* Cheap fix to assure XHTML compliance, this should really happen in prepareAmazonWishlistEntry() */
  $item[TITLE] = htmlspecialchars($item[TITLE]);
  $title = "<a href=\"$item[DETAILPAGEURL]\" title=\"$item[TITLE]\"><span> $dateAdded </span> $item[TITLE]</a>";$output .= "<div>$title</div>\n";
    
  unset($item);
  }
  unset($group);
  }
  
  } else {
  $output = "<p><strong>Error!</strong> There was a problem building your wish list, please try again later.</p>";
  }
  
  echo $output;
  }

Comments (0)

ChaddApril 23rd, 2007 at 4:12 pm

Well I’m glad you got the wish list in. Is there any way that you can get it to not cut off the text though?

Indemnity83April 23rd, 2007 at 4:15 pm

yes and no… I can get it to not cut off the text, but not with the format I wanted. So I decided to deal with cutting off the text (for now).

If you hold your mouse over any link, the full name will pop up (in any modern browser).

I probably wont ever do anything about cutting off the item names, but I am trying to think of a solution for the category names.

I’m open to suggestions.

Leave a comment

Your comment