This mod will generate a well formed XML sitemap for Google in three easy steps.
- Edit your config.php file. If it is best to download config.php from your server and modify it on your workstation so you know you have the correct and latest file. Towards the bottom of the page, you will find this code:
```php ‘logs’ => $targets_dir.‘logs.php’,
); ```
Make it look like this and upload to your server. I assume you know how to FTP.
```php ‘logs’ => $targets_dir.‘logs.php’,
‘google_sitemap’ => $targets_dir.‘google_sitemap.php’,
); ```
- Copy the code below and make a new file called “google_sitemap.php”. I know, how do I create the file? After you copied the code below, open notepad and select “paste” or hit the keys “ctrl” “v” and the sametime. In notepad, click on “File” and choose “save as” and give it the name “google_sitemap.php”. It needs to be placed in the folder called “targets” on your server.
```php
// File: GOOGLE_SITEMAP.PHP
// Description: Google Sitemap Dispatcher.
// Created: 2006-10-12
// Ver: $Id: google_sitemap.php 1 2006-10-12 00:0:00Z lsb $
//
// Copyright 2006 (c) RENS Management, LLC. All rights reserved.
//========================================================================
if ( !defined('IN_CSCART') ) { die('Access denied'); }
if (AREA == 'C') {
include $customer_dir.'google_sitemap.php';
} elseif (AREA == 'A') {
include $admin_dir.'google_sitemap.php';
}
?>
```
3. Now we are going to do the same Copy and Past as before. We are even going to use the same file name “google_sitemap.php”, but inside it is different. Copy the code below and paste it into a new file called “google_sitemap.php”. Now the file will be FTP to two locations on your server. The first is the folder include/customer and the second folder is include/admin.
```php
// File: GOOGLE_SITEMAP.PHP
// Description: Google Sitemap Generator.
// Created: 2006-10-12
// Ver: $Id: google_sitemap.php 2 2006-10-12 00:0:00Z lsb $
//
// Copyright 2006 (c) RENS Management, LLC. All rights reserved.
//========================================================================
if ( !defined('IN_CSCART') ) { die('Access denied'); }
$products=$categories=array();
$categories_all=db_get_array("SELECT category_id FROM $db_tables[categories] WHERE membership_id=0 && avail='Y'");
$products_all=db_get_array("SELECT product_id FROM $db_tables[products] WHERE avail='Y'");
while (list(, $cats) = each($categories_all)) $categories[]=$cats['category_id'];
while (list(, $items) = each($products_all)) $products[]=$items['product_id'];
header("Content-Type: text/xml;charset=utf-8");
$lastmod = date("Y-m-d", time());
$siteurl = utf8_encode(htmlentities("$http_location"));
echo <<
$siteurl
$lastmod
daily
1.0
\n
START;
// process categories
foreach ($categories as $category) {
$link = utf8_encode(htmlentities(“$http_location/$index_script?$target_name=categories&category_id=$category”));
echo <<
$link
$lastmod
daily
0.5
\n
LINKS;
}
// process products
foreach ($products as $product) {
$link = utf8_encode(htmlentities(“$http_location/$index_script?$target_name=products&product_id=$product”));
echo <<
$link
$lastmod
daily
0.5
\n
LINKS;
}
echo <<
END;
exit;
?>
```
Once installed, goto this site and enter the URL to your new sitemap generator. The URL on your site should looks something like this:
[noparse]http://www.mycart.com/index.php?target=google_sitemap[/noparse]
[noparse]http://www.mycart.com/shop/index.php?target=google_sitemap[/noparse]
If everything is working to this point, the next message will show you how to tell Google to use your new sitemap generator.