JavaScript Editor Ajax software     Free javascripts 



Main Page

6.
Load
http://seophp.example.com/urllist.txt.
You should get a Yahoo! sitemap, as
shown in Figure 9-2.
Figure 9-2
The
Sitemap
class creates both Yahoo! and Google sitemap formats via the same class interface. To use
it, you first create an object of the class
Sitemap
, then use the
addItem()
method to add each of your
URLs. That’s what you do in
sitemap.php
:
// create the Sitemap object
$s = new Sitemap();
// add sitemap items
$s->addItem(SITE_DOMAIN . ‘/catalog.html’, ‘2006/10/27’, ‘weekly’);
$s->addItem(make_category_product_url(
“Carpenter’s Tools”, 12, “Belt Sander”, 45), ‘2006/10/27’, ‘weekly’);
$s->addItem(make_category_product_url(
“SEO & Toolbox”, 6, “Link Juice”, 31), ‘2006/10/27’, ‘weekly’);
$s->addItem(make_category_product_url(
“Friends’ Shed”, 2, “AJAX PHP Book”, 42), ‘2006/10/27’, ‘weekly’);
Note that you use the
make_category_product_url()
function from the URL factory to obtain proper
URLs. In a real example, the information provided to this function would be pulled from records in a
database, and not specified directly in application code. But this example again illustrates how using
the URL factory eases programming and enhances consistency.
The last modified date, change frequency, and priority should be provided in the formats elicited by
Google sitemaps. These fields are not included in the Yahoo! sitemap. To create the sitemaps, simply
call the
getGoogle()
or
getYahoo()
methods of the
Sitemap
class, respectively. Your
sitemap.php
script calls one of these methods depending on the value of the
target
query string parameter:
// output sitemap
if (isset($_GET[‘target’]))
{
207
Chapter 9: Sitemaps
c09.qxd:c09 10:43 207


JavaScript Editor Ajax software     Free javascripts