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.











