This guide is meant to compliment the Amazon Products Feed - Beginners guide. If you have not done so, please browse through it first to get a feel for the script. If you have the Amazon Products Feed installed, configured, and working on your server, and are ready to see how to customize the script further...then this is the guide for you. You should always check the project page for updated information and forums for help.
- Templates Results
- Including search results into your web pages
- Advanced Options
- Change Languages
Amazon Products Feed utilizes templates to display the products in a browser, there are several templates, but the most important are the Page, Products, & Item Templates.
The script comes with a default set of templates and you do not need to customize a template if you are happy with how it displays. For example, if you are happy how the item template displays the item, then you do not need to make your own item template the script will use the one from the default directory. You can also use different sets of templates to match different sections of your website, or if you desire a different look.
In this version of the script the templates always use the same names they are just organized in different subdirectories under the template directory.
The default templates are in a subdirectory called default and are named:
If you wish to use a different set of templates you would create another subdirectory, like the wap subdirectory, and use the same names for the files in that location:
Samples of all of the templates can be found in the tar file of the script in the cgi-bin/apf4/templates/default directory.
These templates use variables to display certain content, which makes it easy to design. Decide where you want the item's picture to go and place the variable there in the HTML. When making these templates, it's easiest to look at the sample template to get an idea of how each variable works. For a list of all the variables that you can use, click here. One important thing to remember when using these variables, they must have the correct format or the script will ignore them.
Also remember that these are case sensitive
Is not the same as
You can look here for a comprehensive list of variables, this is just meant to explain how the most common variables work and get you started using variables. To use these variables effectively, simply make the HTML for your page and just plug in the variable where you want the information to appear.
The most important variable is:
Your page template must have this in order to display products. This variable simply places any results of the script at this spot.
Other common variables for your page template are:
Displays either "store : subject" or the linked browse path (i.e. Bestsellers > store > subject) when applicable
Displays the Search Box for APF
Displays next and previous page buttons
Some common variables for your
Displays the name of the product results
Displays List Price, Amazon's Price, & Savings
URL to the current product (use this for linking)
The page template is the basic HTML design of the webpage that the script results will display in. The most important variable you need on this page is
This is where the script will place the results that the user searches for (the products). You must have this on your page template or it will not work. When you save your templates, it's important to name it page.template .
One of the easiest ways to make the script results match your site is to copy the HTML from one of your pages, then build a table where you want the results to appear then add the variables like above.
Now that you have the page template done, you're ready to modify how the products look.
The products template specifies exactly how each product will appear within the page template. The contents of this template are automatically repeated for each product displayed on a page.
The item template specifies how the item information will look when you click on an individual item from the products results page. It utilizes the page template for the main HTML of the page.
There are several other templates that you can use, if you've mastered the page, product, and item templates, you'll have no problem modifying these.
- larger_image_templates - the HTML to display the large product image
- browse_menu_templates - the HTML to display the browse cateogries
- nav_menu_templates - the HTML to display the navigation menu (if used)
The next few templates are used to display the used and third-party products
- sellersearch_templates - the HTML to display SellerSearch results
- sellerprofile_templates - the HTML to display seller profile
- thirdparty_products_templates - the HTML to display third-party products
If you use FrontPage or a similar program to design and manage your site, you can use it to generate a page template. You do have to make a few modifications that are fairly simple. Make a new web page inside FrontPage with the design of your site but the content area blank (easiest way is to copy and paste a web page that has the look you want, then delete the content). Find the spot where you would like the script content to appear and type
Save this file to your desktop and name it page.template. It's important to note how FrontPage writes hyperlinks and images to HTML. Since FrontPage saves all files/images to the same folder, it doesn't specify the directory, but this template will reside in a different directory than your pages and images, so you need to modify a bit.
Open the page in a text editor (notepad is fine) and use the search feature. Search for "href" this will highlight all of the hyperlinks in your page one at a time. If it is a hyperlink that has a full URL already, don't modify it.
By default FrontPage saves them as:
You simply need to specify the URL, change this to
Same idea for your images, search for "src", and change
If you use background images anywhere in your site, search for "background" and change:
As soon as your done, save the file, then FTP it to the proper subdirectory on your server (/cgi-bin/apf4/templates/whatever/)
To modify the results that the script produces, you can specify it in the URL.
You take the initial URL of the script
and add the variables after it with the first variable preceded by a ?
More variables can be added with all of them preceded by a &
The most commonly used URL options are
To use these 2 options, take the initial URL of the script:
Then let's say you want to browse in books (mode=books):
Then we want to look at Computer & Internet books (id=5):
By default, the script will use the set of templates in the default subdirectory, you can use the URL to switch to another template:
To use the search feature with the URL:
By using link_templates, you can display your products using one set of templates, but make all of those templates link to another set of templates. Very handy if you are using SSI Includes to display products on your pages:
The script automatically returns the first 10 results which is the first page, to link to other pages:
Let's say you want to change them to alphabetically:
For all values for sort click here
To link to a specific product:
All available URL options are listed here.
To add a search box to other pages of your site, simply cut-n-paste the code below:
<form method="get" action="/cgi-bin/apf4/amazon_products_feed.cgi">
<input type="hidden" name="Operation" value="ItemSearch">
<input type="text" name="Keywords" size="20" />
<option value="Blended">All Products</option>
<option value="Classical">Classical Music</option>
<option value="Kitchen">Kitchen & Housewares</option>
<option value="OfficeProducts">Office Products</option>
<option value="OutdoorLiving">Outdoor Living</option>
<option value="PCHardware">PC Hardware</option>
<option value="HealthPersonalCare">Personal Health Care</option>
<option value="SportingGoods">Sporting Goods</option>
<option value="Tools">Tools & Hardware</option>
<option value="Video">Video (DVD & VHS)</option>
<option value="WirelessAccessories">Wireless Accessories</option>
<input style="background-color:#FFCC68;color:#000068;font-weight:bold" type="submit" value="Search" />
You can insert search results into any of your web pages using a couple of ways. Search engines will even index these as part of your web page.
This stands for server-side includes, which means that when the page is requested by the users browser, your server combines this with the rest of the HTML. To do this, most hosting companies require that your pages have .shtml extensions. You can try to use these with .htm extensions to see if it will work, and some hosting companies let you specify .htm pages to utilize SSI Includes. But you need to contact your hosting for details on that.
To use an SSI Include, it's very simple, let's say you want to display the top selling video games, then from your URL:
To include these results, remove the domain name from the URL and use this
Now one roadblock to this, is it will display all of the content from your page template as well. So you should modify your page and products template to get the results you want.
Basically a page template with just:
This will work, since you don't need the <HEAD><TITLE> elements. And maybe a simpler products template so it won't take up as much room.
You should only use a php include if your pages are coded in php because they require the .php extension to run properly. If your pages are not php, use the SSI include above.
To do the same example as above with php use:
APF options were designed so you can customize your templates even further than standard HTML. The options and the HTML they affect are enclosed in a special comment tag.
Notice the exclamation points, they separate the different parts of the command. <!--apf tells the script that options will follow. All options must be proceeded by an & to separate them and the last option is indicated by following it with an !. Anything following that ! through !--> is considered the HTML you want to control. If the option doesn't contain HTML, like for including a text file, the exclamation points still need to be there. The examples below will show how these options can be used.
Product to start using the HTML at. This is optional if it is not specified the HTML starts with the first product.
Last product to use HTML at. You can use the word last
to specify the last product. And this option will always add the HTML to the end product, which is necessary to close off any open <TR>s.
How often to repeat the HTML. If 1 use with every product, 2 every other product, 3 every third, etc.
Include a text file or nav_menu. If you have HTML that you use on many pages (like the menu links at the bottom of all of my pages) you can use this option to include that file in the template. See example 3 below to better understand this feature. See
to understand how to include the Navigation Menu
If you look at this page. The product tables have alternating colors. This isn't possible with standard HTML inside the templates, but it is with APF options. To alternate colors for every other table, use this in the top of your products template: This would replace the normal <TABLE> tags in your products template, after this you would use the <TD> tags and any other HTML that will be the same for every product.
The first <!--apf tag tells it to repeat this HTML for every other result (apf_repeat=2)
<!--apf tag tells it to start at the second result (apf_start=2) then repeat this for every other result (apf_repeat=2)
<TABLE Bgcolor="#CCFFFF" Border="6" Cellpadding="10" Width="100%"><TR>
<TABLE Bgcolor="#FFFFFF" Border="6" Cellpadding="10" Width="100%"><TR>
So what you get as a result:
The next example will build your products into rows with 2 products on each row.
The first <!--apf tag starts the row (<TR>) and repeats it for every other product (apf_repeat=2)
The second <!--apf tag closes the row (</TR>) starting with the second product result (apf_start=2) repeats it for every other result (&apf_repeat=2) then finally adds the closing tag to the end of the results (apf_end=last).
Click here to see how these results look when finished.
So as a result you get:
|Product #1||Product #2|
|Product #3||Product #4|
APF can also be used to include a text file into a template, similar to how an SSI Include would work.
This will look for a file called "footer.html" and plop it in the spot. If you use navigation or footers on your other pages and include them with SSI, you can use this to do the same in a template.
If you look at this page you may notice a navigation menu on the left of the products. This menu changes as you choose different categories. It will display the different sub-categories for whatever category you are in. You can change how this looks by modifying the nav_menu template. To use this in your page use the following tag in your page template above your %%products_html%% as in this sample page template. This utilizes the APF Options described above.
<TD Align="left" Valign="top" Width="160"><TABLE Bgcolor="#FFDC91" Width="100%"> %%nav_menu_html%%</TABLE></TD>
The Navigation menu uses the nav_menu.template.
Languages work like the templates. Simple text files of all the variables that contain the text the script displays that does not come from Amazon. If you wish to create your own language file please use the sample English file as a starting point and be sure and send us a copy so we can share it with others. We would like to provide as many different languages as possible.
You specify which language to use in the URL with language. &language=french
To display multiple languages in HTML there is a special charset (character set) called Unicode. This is the format that Amazon sends their results in and so it is what my script uses. To use accented characters in the language files you must use Unicode entities. Entities are just (a number);. I wrote a script to display the characters and show the entity for each so you can use them in your language file - Unicode Generator.
This documentation is a derivative work of one originally created by OneClickDesigns.com