Reality Hammer (reality_hammer) wrote in component_help,
Reality Hammer

  • Mood:

Yet another book list

Main difference between this and other examples: this one links to using an Amazon Associates id.

This is useful if you have an account with Amazon and want to make money when people click through to Amazon from your journal.

print_comp_header("Recommended Reading");

var Color  image_border_color = "#000000"; # bordercolor for images
var Color[]  image_bg_color;

$image_bg_color[0] = "#FFFFFF"; # bg color for images (alternates)
$image_bg_color[1] = "#DDDDDD"; # bg color for images (alternates)

var string amazon_id = "/your Amazon Associates ID goes here/";
var string link_prefix = "";
var string image_prefix = "";
var string image_postfix = ".01.THUMBZZZ.jpg";

var string[] book_link;
var string[] book_title;

# books
$book_link[0] = "1400040310";
$book_title[0] = "His Excellency: George Washington";

$book_link[1]   = "0689870434";
$book_title[1] = "When Washington Crossed the Delaware";

# you can put as many books/videos/etc as you like here

<div id="layer_one" style="position:relative; width:100%; height:200px; z-index:1; overflow: auto; overflow-x: hidden;">
<table width="100%" cellpadding="3" cellspacing="0">

foreach var int i (0 .. (size($book_title) - 1))
  <tr style="background-color:$image_bg_color[$i % 2];">
  <td style="text-align:left;">""";
if($book_link[$i] != "") { """<a href="$link_prefix$book_link[$i]$amazon_id">"""; }
  """<img src="$image_prefix$book_link[$i]$image_postfix" border="0" style="border: 1px solid $image_border_color" align="middle" alt="See at Amazon" />""";
if($book_link[$i] != "") { """</a>"""; }
  <td style="font-weight:bold; text-align:left;">""";
if($book_link[$i] != "")
  { """<a href="$link_prefix$book_link[$i]$amazon_id">"""; }
if($book_link[$i] != "")
  { """</a>"""; }




Note: thanks to kunzite1 for the inspiration/basic LJ code. I ported this from my old Xanga journal (which inserted your Amazon code automatically). This code is meant to be used in a free text override (see the component tutorials).

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 1 comment