Amazon Links in Textpattern

48 days ago

Here’s a (Textpattern) code snippet someone might find interesting; this is the form to generate the Amazon links in my right sidebar. I think it’s an elegant solution to the problem of creating Amazon affiliate links:

<li><a rel="nofollow" href="http://www.amazon.com/exec/obidos/ASIN<txp:link_url />/adamtb-20">
<img src="http://images.amazon.com/images/P<txp:chh_if_data><txp:link_description />
<txp:else /><txp:link_url /></txp:chh_if_data>.01._SY75_.jpg"  alt="<txp:link_name />"  
title="<txp:link_name />" /><br /><txp:link_name /></a></li>

The “Link URL” field contains only the ASIN, Amazon’s product ID number. That makes it possible to use it both to generate a product URL and to pull product images, a process amusingly described by Nat Gertler in Abusing Amazon images.

The one likely-confusing bit from this snippet is here:

<txp:chh_if_data><txp:link_description /><txp:else /><txp:link_url /></txp:chh_if_data>

If there is content in the link’s description field, this will assume that text is an ASIN and use that instead of the link URL. I set this up after realizing that the ASIN can’t be used to pull images for some products on Amazon (notably MP3 downloads). This makes it possible to pull an image using an alternate ASIN title.

atb_image_pulldown

Easily assign article images.

163 days ago Screenshot: atb_image_pulldown

atb_image_pulldown is a simple plugin that replaces the Article Image text box with a pulldown list showing all images in order by category and name. This should make it fairly easy to assign article images, assuming you use well-chosen names for images and categories. There’s no configuration unless you’re using another plugin to enable multiple article images, then there are some options in the plugin code to replace the pulldown list with a multi-select list box.

Download: atb_image_pulldown_v021.txt