More PHP Editing

I edited the PHP on the WP-Amazon Plugin for WordPress. I wanted to achieve two things. One, when adding an image, I wanted the text to follow it. Two, I wanted to have it display the name of the product in the title attribute of the link, that is, when one hovers over the link, I wanted the title to display, rather then the default of "View product details at Amazon".

Here is the new improved code:

PHP:
  1. function generateHTMLCode(format,prodname,url,imgurl) {
  2.     if (format=='link') {
  3.         html = '<a href="'+url+'" title="Amazon.com - '+prodname+'">'+prodname+'</a>';
  4.     } else {
  5.         html = '<a href="'+url+'" title="Amazon.com - '+prodname+'"><img src="'+imgurl+'" alt="'+prodname+'" /></a><br />'
  6.         +'<a href="'+url+'" title="Amazon.com - '+prodname+'">'+prodname+'</a>';
  7.     }
  8.     htmlCode = document.getElementById("htmlcode")
  9.     htmlCode.value = html;
  10. }

Here is the old code so one can find it. It should be around line 190 or so (for version 1.3.2 anyhow)

PHP:
  1. function generateHTMLCode(format,prodname,url,imgurl) {
  2.         if (format=='link') {
  3.                 html = '<a href="'+url+'" title="View product details at Amazon">'+prodname+'</a>';
  4.         } else {
  5.                 html = '<a href="'+url+'" title="View product details at Amazon"><img src="'+imgurl+'" alt="'+prodname+'" /></a>';
  6.         }
  7.         htmlCode = document.getElementById("htmlcode")
  8.         htmlCode.value = html;
  9. }

I am still looking for a way to change the link to a more basic link, so Amazon's new Product Preview will work properly. However, for some reason I can't figure out where it is making the full link...

About Brian A. Thomas

I am the father of Ari and Sidd. I am the owner and administrator of this site.
PHP, Programming, WordPress , , ,

2 responses to More PHP Editing


  1. superfish

    hello. is there an easy way within wp-amazon to display a widget block with a random image and title somewhere in the widget sidebars?

    perhaps by using a phpexec widget with a call?

    (p.s., yes, i know about the cg-amazon plugin)

  2. That may be above my current PHP abilities. I would say contact the author of the plugin itself and see if he knows, although I am not sure if it is still in development. I am still trying to find a way of changing the links to a basic link so the product preview will work.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>