Your Web Site, Search Engines, and a Bookshop
7. Now it's time to generate some sample results. You're going to run the script dofind.php, which will do a search on the default sample term "Spokane" supplied in customize.inc (useful because it supplies perhaps 30 titles in a search that runs in seconds). When you click on the link that you'll be given a little below, the script will run and produce an output screen. It will show a column of entries of the form INDEX nn; each of those is a 10-book page fetched from Amazon as XML (which you don't really need to know about). Since the script dofind.php also automatically runs the script holders.php, you will see listed first the 28 confirming file-make statements from it.
In sum, the browser screen you get should look something like this:
(The BEGUN number is the number of data pages the script will have to fetch from Amazon; the INDEX entries are those pages being fetched and processed--10 titles a page, except possibly the last; and the rest is self-explanatory.)
Note! some browsers do not display a "page" till they have loaded it in full, which--in this case--means till the php process is complete; so, even if your browser screen does not change, as long as your browser's "loading page" indicator (typically a little image in the upper right of the browser window) shows activity, the search is in process, so Don't Panic.
OK, click away and here we go (this should take about 20 seconds).
8. Now let's look at a sample results page.
Let's look at the page for letter-M titles, which is book-titles-M.shtml. (There will be 28 similarly named files. 26 are obvious alpha files; of the other two, book-titles-@ is titles that begin with non-alphabetic characters--typically numerals)--and book-titles-~ is titles that begin with your keyword search phrase, which is broken out as a separate page of listings so they don't clog up the alpha page they would otherwise fall under.)
For now, you are really just getting a feel for what you have. If the general look-and-feel of the page seems more or less OK, fine, but if not, you can completely modify every aspect of these title-listing pages except the individual-title blocks, and even for those you can customize the background color, the text color, and (within limits) the text size--so you really can get almost any look you want here.
(The drop-in-block values are set in your customize.inc file, as is explained in that file; the rest of the page you change by modifying holder.shtml, the template from which they all derive.) I strenuously recommend that you not rush into any such fiddling till you have finished the install and have thoroughly read all the package docfiles.
I have made all files that will actually be in your site .shtml files, so you can do server-side includes--and, in any event, some of them need to be for this package. (I have also tried to make them all, including the php-generated ones, scrupulously correct XHTML v. 1.0 Transitional, but you should use the W3C Validator to check them when you're finished customizing.) Later on, at your leisure, read the file CustomizingPlus for advice on how to customize these 28 alpha title-listing pages through customization of holder.shtml.
9. Now it's time to determine the real Amazon keyword search word or phrase you will use to build your real results. You will do this by an iterative trial-and-error process in which you seek a plausibly site-relevant word or phrase that will give you an appropriate number of titles to list.
Your Amazon-search "keyword phrase" can be a single word, or several words; if it is more than one word, just separate the words with blank spaces. Multiple words in a phrase are "and'ed": titles are returned only if they are relevant to every word in the phrase--so using more than one word always acts to narrow down the results, with each extra word further narrowing the field.
Sometimes the selection process is natural and easy; a site whose theme is "vegetable gardening" would find that simply using Vegetables would return a satisfactory number of results. But sometimes the selection requires some thought if your first couple of stabs yield only low--or ludicrously high--totals. There is, though, always a satisfactory phrase if you just think about it long and hard enough.
You will effect this trial-and-error effort by using a one-time-use package tool called bookcount.php. This tool will report, in a second or three, the following--based on what keyword search phrase you are trying (at its first run, it will use the default word listed in your current customize.inc file)--in a form like this:
177 (for this example) is the actual number of titles Amazon would return; it is a definite number. But this package--as a service to your visitors--will strip out all books that are not actually available to be bought at the moment (typically they are out of print, but Amazon does not delete them from its catalogue). For most fair-sized lists of titles, typically about 70% that Amazon has in its catalogue will not really be buyable; the script gives you a rough estimate that is from 25% (here, the 44) to 35% (here, the 62) of the "raw" total Amazon reports, plus a 30% centrum (here, the 53 figure).
(Rather obviously, "Spokane" would be a terrible choice for a search keyword; indeed, it is the default provided just because it produces so few titles, making it a fast first-trial run.)
You can now try different words and phrases using bookcount.php; you can begin by typing a first trial into the box shown above, then pressing your Enter key: that box will actually work, but you will then leave this document and be looking at actual output from bookcount.php. Keep trying various words and phrases till you have one whose titles count you are satisfied with. Carefully note it down somewhere, then return to this document by using your browser's Back button (which might take multiple uses of that button).
(If you still, after reasonable effort, having trouble getting results of a size you are comfortable with, check the package docfile ComplexSearches.html to see how to construct--you guessed it--more-complex searches.)
Now edit your settled-on word or phrase into your local copy of customize.inc (at Step #2 therein)--and pay attention to the notes.
While you're at it, this is the time to also edit some of the other data in customize.inc, especially those at Steps #3, #4, and #5 (you may want to wait to edit the data at Steps #6, #7, and #8 till you have further customized your holder.shtml template file). When you're done, upload the edited customize.inc as described below.
(Follow that procedure for uploading any package file modified since the original install upload, unless it's a file going into your root directory.)
10. Now you are ready to do the search that will actually establish your real bookshop. Before you do, I remind you that as your search runs your browser may not show anything save "page loading" till the whole search is complete. (Later on you will be shown how to start the process as a daemon, so you don't have to sit waiting for it.) To guesstimate the run time, reckon on about ten raw titles a second; thus, a search that will produce about 7,200 raw titles (which you might expect to yield roughly 2,160 final titles) will take about 720 seconds, or 12 minutes. But one that seeks out 32,000 raw titles can take a solid hour or so.
When your run is done, you will again see a column of INDEX xxx text and at the bottom the word FINISHED; till you see FINISHED, the script is still running.
(Reminder: it is wise to start the run in either a new browser tab, or--if you don't have tabs--a new browser window.) Start the process, then return here so we can do some things while it's running.
Here's the link to start the search process.
11. While you are waiting for the search process to finish, use the time to customize the two root-directory files you need to work with.
11a. First, your robots.txt file: this is a file that must (or it won't work) reside in your site's root directory (the one where your front page is). The finstall.php script will have reported to you whether you have one, and, if so, what it contains (but that's only a help--look manually to be sure!).
If you have one, just add the lines from the included sample into it. (Download it, edit it, and upload it back.) If you are absolutely, positively sure that you don't have such a file now, just rename the one included with this package to robots.txt (that is, drop the .SAMPLE extension) and upload it to your site's root directory.
All the added (or new) text does is tell search-engine robots to not attempt to follow any links from the files affs.php or abe.php--thus, any outbound link sent through those forwarders will be invisible to search engines. If you don't do this, you will needlessly bleed some overall site Page Rank (to Abebooks for one thing). (By the way, each of those thousands of lovely new pages will have a backlink pointed at your site's front page.)
11b. Now for your .htaccess file. Because this file is very important to you and your web site, and what you do to it is (though, for this package, very simple) critical, I have provided a separate docfile just about the .htaccess file. If you are an old pro with such files, excellent--you probably know a deal more than I do. But if you're not an htaccess guru, you may learn some interesting things. At any rate, what exactly you need to do, and just how to do it, are in the package file YourFile: please read that now, then return here when you're done. (As you leave here for now, recall that your browser is, presumably, still spinning on your book search.)
12. When your browser search tab or window shows--as described above in Step 10, where you started your book search--that the search run has finished, it's time to see what your new bookshop looks like so far (you still have significant customizing to do).
Eventually--after you have properly customized it--the file mybookshop.shtml, placed in your site's root directory, will be the "front door" to your new bookshop, and an integral part of your site. Right now, you haven't customized it, and there is no copy in your root anyway. So, for the moment, you will look at your shop through a special setup-use-only file that the installer made for you, shoptest.shtml, which is basically mybookshop.shtml with the links reset so that they'll work for a file at this level in your site directory.
You will be looking at your new bookshop as your site visitors (and search engines!) would see it (and you will see why the page needs customizing!). Explore your 28 end-product "real" or "static" pages; try clicking on some titles, and make sure that everything there looks OK too.
(And recall, as you try various individual titles, that not all books will have reviews at Amazon, nor will all books have cover images available for them, so keep poking about till you have seen a fair number of samples.)
OK, So now click and look around (preferably in a separate tab or window).
13. If you have reached this point still in a happy frame of mind, your remaining chores are few. You need to customize two files--mybookshop.shtml, your new shop's "Front Door", and holder.shtml, the template for the 28 title-list pages--to properly reflect, you, your site's theme, and your site's "look and feel"; there are extensive directions explaining what you need to do and what you can do in the separate package docfile CustomizingPlus.html.
You also may need to customize one line in the file amazon-message.shtml, the one down near the very bottom that reads:
<b><a href="http://www.1st-beginners-golf-swing-tips.com/mybookshop.shtml">the bookstore page</a></b>.
(but with whatever your site's domain is); if you have chosen to give that file a different name (such as widget-books.shtml), be sure to modify that line accordingly!
You should also give thought to customizing the two ancillary search files, book-search.shtml and used-books.shtml for "look-and-feel" compatibility with the rest of your site.
14. Finally, when all is ready, you need to find a way to be sure that the dofind.php search gets done anew daily.
So you could, at worst, manually start it every day, or night, in that manner. But that's needlessly tedious.
Your host should have available to you a scheduler that allows you to set jobs to be auto-executed at some time and frequency you choose; typically--and especially on an Apache-based server--that scheduler will be cron; but what it is doesn't much matter. The way you use it is to set the job to be executed as the special script, provided for this purpose, cronf.php, which of course is in your /golf-books/originals/ directory.
How exactly you set cron to run a php script can vary from server to server, and will depend in part on whether your host runs php as an Apache module or as a cgi-wrapper process. You need to confer with your host if you don't already know how to start php scripts from cron on that host but, as general background information:
The cronf.php file has already had its file-access permissions set to 777; cron typically requires a 7xx setting, so you're ready.
If your php is cgi-wrapped (as many are), your cron command needs to call php and pass it the location of cronf.php as a parameter; that often will look something like:
If your host's php is just the Apache module, you should be able to simply pass the script's location as the cron command, something like:
Some Important Further Package Notes:
And don't forget to go read CustomizingPlus.html and edit those few pages wanting customization! Do it now!
If you don't--especially as regards the "front page", mybookshop.shtml, or whatever you've called it--your shop will work, but will look rather strange to visitors! (Unless your site really does sell widgets . . .)
Otherwise, though, you have a working bookshop: just link to it when you've finished the page customizing.
My name is Eric Walker. Email me at email@example.com. I am glad to work at length with anyone seeking to install and use this package.