<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0" 
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  xmlns:admin="http://webns.net/mvcb/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

<channel>
<title>My Messy Workbench: Instruction Manual</title>
<link>http://www.synaptic.bc.ca/MyMessyWorkbench/archives/instruction_manual.xml</link>
<description>A disorganised shambles
obscuring the occasional gem.</description>
<dc:language>en-us</dc:language>
<dc:creator>eBlog@synaptic.bc.ca</dc:creator>
<dc:date>2004-06-21T00:36:59-08:00</dc:date>
<admin:generatorAgent rdf:resource="http://www.movabletype.org/?v=2.661" />
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>

<item>
<title>Amazon Products Feed: Display the Most Popular Items</title>
<link>http://www.synaptic.bc.ca/MyMessyWorkbench/archives/2004/06/amazon_products_feed_display_the_most_popular_items.php</link>
<description>About apf_pop.cgi
MrRat&apos;s amazon_product_feeds.cgi script (APF) is a marvellously useful script. It&apos;s robust and nimble interface provides rich opportunities for exploitation. Here&apos;s a script most webmasters of APF sites will find useful.

The apf_pop.cgi script searches your website&apos;s access log for specific kinds of APF calls that indicate a user clilcking on an item and grabs the Amazon ASIN&apos;s from them. The ASINs are counted and sorted, then one or more documents are constructed to display them. 

In addition to the data formatting templates available through APF, apf_pop adds an additional templating layer with its own variables. The type of document apf_pop can generate is virtually unlimited: HTML, SHTML, PHP, CGI, even output an APF template, if you like. As this implies, through apf_pop you can display data generated by APF in either dynamic or static documents. 
&lt;br /&gt;&lt;br /&gt;<![CDATA[          Templates

First, things first: design an apf_pop template. It can be based on any type of 
          document. Several template variables are available to help. We'll begin 
          with the core variables. 
          ASIN Data
There are two options for determining how ASIN data is to be placed in your files. 
          Only one or the other of these variables can appear in a template file. 
          %%Popular_ASIN%%
In the output file, this variable is replaced by a comma-delimited list of ASINs suitable for an APF AsinSearch. Examples:

            &lt;!--apf &amp;apf_include=amazon_products_feed.cgi?
			&nbsp;&nbsp;&nbsp;&nbsp;search_type=AsinSearch&item_id=%%Popular_ASIN%%!--&gt;
             &lt;!--#include virtual="/cgi-bin/amazon_products_feed.cgi?&nbsp;&nbsp;&nbsp;&nbsp;search_type=AsinSearch&item_id=%%Popular_ASIN%%" 
              --&gt;
             &lt;a href="/cgi-bin/amazon_products_feed.cgi?
			&nbsp;&nbsp;&nbsp;&nbsp;search_type=AsinSearch&item_id=%%Popular_ASIN%%&gt;The 
              Top 10!&lt;/a&gt; 
          
The first example is, of course, useful for APF templates. It will expand to a formatted list each time the template is parsed. The second can be placed in any SSI parsed file. The list of Amazon items will be generated each time the file is accessed. The third is a simple link you can place anywhere.
%%Popular_HTML%%
When apf_pop encounters this template variable it calls APF,  passing it the ASINs. APF returns data formatted by the APF template set you specify in apf_pop. Finally, apf_pop parses the data, performing some error-checking and data reformatting, before writing the refined formatted data to the output file. PHEW!This one requires a bit of tricky configuration to setup, but %%Popular_HTML%% offers some distinct advantages over %%Popular_ASIN%%.
Static Pages: Unless your APF templates are doing something unusual, the resulting formatted output is suitable for static HTML pages. This will reduce server overhead, bandwidth and user frustration. Yay!
Heavy data: You can use a 'heavy' version of APF rather than the default 'lite' version to generate these static pages. If your site has  heavy traffic in DVDs and Videos, your users may appreciate the Director and Starring links apf_pop provides via APF 'heavy' calls.
Error checking: apf_pop pulls those annoying "There are no exact matches" and "Invalid Asin" messages right out of the data stream and discards them so your visitors never see them.
There is a niggly drawback to %%Popular_HTML%%
Multiple APF scripts: Whether you elect to create a 'heavy' APF for apf_pop's use or not, you'll want apf_pop to call a copy of the  APF script with a different name than the one called when users click on your site's links. This is due to the way apf_pop gathers ASINs from the log file. I'll explain why in some detail later on. The distribution zip contains some tools for diminishing the burden.

The remaining template variables can be used in both the ASIN and HTML context.

%%see_prev_popular%% and %%see_next_popular%%
These will place Next and Back buttons for navigating between pages created by the call to apf_pop.
%%Popular_Page_Count%%
This is replaced by a "Page 3 of 4" message.

More template variables are coming in future versions of this script.

Configuring apf_pop for %%Popular_ASIN%%

We'll begin with the simpler case, configuring apf_pop for a %%Popular_ASIN%% template. There are several variables which must be defined in the script.

General script setup
$max_pages = 20
$items_per_page = 5;

Pretty straightforward. In this example apf_pop will create up to 20 pages listing 5 items per page.

$Popular_var_type = "ASIN";

Tells apf_pop to look for %%Popular_ASIN%% in the template file and replace it with a string of comma delimited ASINs in the output files.

logfile parsing
;
$logfile =  "/home/username/logs/access.log"
Specifies is the log file apf_pop will scan for ASINs. Include the full server directory path as necessary so the script knows where to find it.

$logfile_get_string = "\"get /cgi-bin/Amazon/amazon_products_feed.cgi"

This character string identifies the lines in your logfile representing APF activity. apf_pop will parse these lines for AsinSearch. It's important that this string ignores the log entry's referrer data, so that only user activity to view an ASIN is counted, and not all the times the user clicks another link on that page. $logfile_get_string can be a regular expression; apf_pop will give the string a once-over to assure special characters have been escaped properly.

Logfiles can be quite large so keep this string short to minimise the amount of processing apf_pop must do. The format of the string in the example above will work fine in most instances. "\"get" identifies the opening of a page and is followed by the URL of the page to be opened. Folks on unix servers can test this out using grep. EG:


grep "\"get /your/path/amazon_products_feed.cgi" access.log &gt; apf.log


The file "apf.log" will contain the results. It's likely to be big, so don't forget to delete it.

apf_pop template setup
$template_file = "/home/bv126070/public_html/cgi-bin/Amazon/popular_list.template.html";

Identifies the template used by apf_pop to generate the output pages. Include directory path as necessary.

$nav_target = "_top";
Specifies the link "target" for links generated  for %%see_prev_popular%% and %%see_prev_popular%%,  $nav_target = "_self" is useful for popular pages placed within FRAMESETS or IFRAMES, otherwise, "_top" works well. If you specify an empty string, then the links will have no target.



apf_pop scans the access log for entries containing an APF AsinSearch. If the item_id field contains only one ASIN, then apf_pop counts it as a click and grabs the ASIN.]]></description>
<guid isPermaLink="false">294@http://www.synaptic.bc.ca/MyMessyWorkbench/</guid>
<dc:subject>Instruction Manual</dc:subject>
<dc:date>2004-06-21T00:36:59-08:00</dc:date>
</item>
<item>
<title>IFRAME and Amazon Product Feed:</title>
<link>http://www.synaptic.bc.ca/MyMessyWorkbench/archives/2004/06/iframe_and_amazon_product_feed.php</link>
<description><![CDATA[How to display inline searches in your templates and pagesA Newbie Tutorial

On my HTML pages I figured out how to use SSI to display the results of amazon_product_feed searches on my web pages. However, Neither the SSI or PHP methods described in the documentation will work if placed within the templates.  I've got this great sidebar in my page design but very few of the useful Amazon Product Feed variables are available at the page template level. What to do?

There are two HTML options &lt;OBJECT&gt; and &lt;IFRAME&gt;.  These are fairly well supported on the more popular browsers, though OBJECT is the only one of the two specified in the HTML 4.0 standards. Nonetheless, I went with IFRAME for some of its more useful features.
]]>&lt;br /&gt;&lt;br /&gt;<![CDATA[
Two HTML options &lt;OBJECT&gt; and &lt;IFRAME&gt;.  These are fairly well supported on the more popular browsers, though OBJECT is the only one of the two specified in the HTML 4.0 standards. Nonetheless, I went with IFRAME for some of its more useful features.

It took some immersion in HTML references and some code from additional sources to get all this working, but it's not rocket science. An IFRAME is just a window layered on top of your main window. You can display stuff in it in much the same way you would the main browser. We're going to make it as transparent and flexible as possible. It's quite amazing the results a couple lines of code can produce!  Well, there is a bit more to it than that...

Setting Up the Frame


&lt;iframe name="sidebar" id="sidebar" align="top" allowtransparency="true" 
    marginwidth="4" width="100%" height="750" 
    scrolling="auto" frameborder="0" 
    src="/cgi-bin/Amazon/amazon_heavy_products_feed.cgi?
    mode=blended&search_type=SimilaritySearch&input_string=%%Asin%%
    &templates=4&link_templates=1&max_results=6&link_max_results=10"&gt;
    
          Sorry, your browser does not support IFRAMEs

&lt;/iframe&gt;


So we have a child frame appearing in the parent window with the following configuration

An IFRAME named "sidebar" (we'll be using that later),
that will hopefully force itself to display at the top of the sidebar 
it's transparent so whatever colour our sidebar is will show through
as wide as the parent sidebar (less 4 pixel margins on each side)
will automatically put up scroll bars if there's more data than fits in the frame.
won't have a border because we already have one in the parent sidebar.
browsers which don't support IFRAMES will display the message instead.


Nifty. Now inside that IFRAME is a call to the APF script. This call will perform a similarity search on the current value for %%Asin%%. It's calling a special 'heavy' version of the script which I've lightly hacked in order to get the "heavy" data from AWS, in order to display %%Director%% and %%Starring%% information when available. There's more to this call, but we'll get back to that.

For now, let's finish off the IFRAME implementation.

Resizable IFRAMEs

We've configured our IFRAME to be 750 pixels in height. That's fine when you know how much data the search will return, but we don't. In order to make it resizable, we have to get the IFRAME window and its parent window to have a conversation. "Hey Dad!" "Yes, son?" "I need to be T H I S  B I G !!!" Except they're going to talk in javascript. There's a simple example of this here found on this page. I'd save you all the digging, but the code's Terms of Use prevent me from redistributing it. Instead, I'll tell you what you need to do.

First, view the source code of this page and find the line 


&lt;script type="text/javascript"&gt;


Copy that line and everything following it until you get to 


&lt;/head&gt;


and paste the whole block into your parent page somewhere inside the the &lt;head&gt; container.


]]></description>
<guid isPermaLink="false">289@http://www.synaptic.bc.ca/MyMessyWorkbench/</guid>
<dc:subject>Gems</dc:subject>
<dc:date>2004-06-04T21:46:25-08:00</dc:date>
</item>
<item>
<title>Posting to cOUNTER fLOW</title>
<link>http://www.synaptic.bc.ca/MyMessyWorkbench/archives/2004/02/posting_to_counter_flow.php</link>
<description>cOUNTER fLOW is a sideblog intended to generate a list of links in a sidebar. You&apos;ll see it performing its intended job lower down in the sidebar of the index page. However, it didn&apos;t take long for it to grow into a regular blog, with categories, RSS feeds, comments, the whole lot. 

If you would like priviliges to post links in cOUNTER fLOW, you&apos;ll first have to cut your teeth in the eJournal Message Forums. A few dozen entries should be enough for us to determine whether your editorial sense is what we&apos;re looking for.&lt;br /&gt;&lt;br /&gt;For those with posting privileges, here&apos;s what you need to know.

Basic Posting

Because it&apos;s configured to be a sideblog, cOUNTER fLOW utilizes the Movable Type edit fields in an unusual fashion.

Title
Well, Title is pretty straightforward--the title of your link. Usually, the real name of the page you&apos;re linking to.

Body
The Link.  Specify the full URL, eg: http://www.worldpeace.ca/InMyLifetime.htm
Don&apos;t put anything else in here. Test the link...before and after posting.


Extended Entry
Write the blurb here. Keep it short. Shoot for 50 words, but don&apos;t sweat too hard if you go over by a few, or more than a few. You can use basic HTML for formatting, more links, etc. but keep it simple. 

The principle: entice the reader to visit the page within a brief summary of what they&apos;ll find there. You are allowed to interpret &quot;summary&quot; creatively.

Categories
This is important: cOUNTER fLOW categories describe the primary content of the linked site. When applying categories, consider the following:


Categories are intended to help visitors find information. A large political site that contains a few articles on feminist topics is not a Feminism site. (If the information in those pages is valuable to people searching for feminist topics, link to them individually.) A site placed in any category should be considered a primary or secondary resource for that category.

Sites with a broad focus can fall into multiple categories. However, consider the theme and focus of such sites before you fill the cornucopia. CorpWatch fits Corporate and, arguably, Political (but not Globalisation); FAIR fits Media and Political.  They are both political, because of a strong progressive agenda.

The Media category is intended for analysis and commentary on media, not &quot;media sites&quot; like CNN, BBC, NYT, etc.

The Headlines category is intended for links to individual articles not links to publishers like NYT, CNN, etc. Generally, use the title of the article for the title of the post.

There is no Rant or Drivel category. Don&apos;t post sites which would fit into one.

There are no Left, Right, Conservative, Anarchist or Libertarian categories. All political denominations fall under Political. Make spectral distinctions in the blurb as you deem fit.



Additional Edit Fields

You don&apos;t have to worry about them.  I&apos;ve got the defaults set so they take care of themselves pretty much. There is a &quot;Keywords&quot; field which gets placed in HTML document headers to help search engines find your page. It&apos;s a good idea...not that I ever do anything with it.

If you save your post, and it doesn&apos;t show up on the site, check the Post Status field and make sure it&apos;s set to Publish and not Draft when you save.


A bit more about the blurb.

If you&apos;re writing your blurb and are tempted to be snide or toss in an ad-hominem, reconsider wether the link is appropriate. For example, Project for a New American Century scares the livin&apos; bejezus out of me, but I can write a blurb which focusses on the significant and important information available on the site. On the other hand... capitalism.org .... If you&apos;ve found something you personally consider beneath contempt and simply cannot resist announcing it to the world, then post it to Awful Link of the Day

Summary.

If you&apos;ve got any questions, don&apos;t hesitate to ask.

Oh yeah, I almost forgot. The legal stuff:

I reserve the right to edit or delete any posts published on cOUNTER fLOW. I believe in a free press and all, but this is my press and I&apos;m the editor.

Looking forward to following your links!

p.</description>
<guid isPermaLink="false">203@http://www.synaptic.bc.ca/MyMessyWorkbench/</guid>
<dc:subject>Instruction Manual</dc:subject>
<dc:date>2004-02-12T20:31:57-08:00</dc:date>
</item>


</channel>
</rss>
