Google Sitemap Generator

This mod will generate a well formed XML sitemap for Google in three easy steps.


  1. 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’,

    ); ```


  2. 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.

If everything is work to this point, the next message will show you how to tell Google to use your new sitemap generator. Once installed, goto Google:



[url]https://www.google.com/accounts/ServiceLogin?service=sitemaps&nui=1&continue=https://www.google.com/webmasters/sitemaps/siteoverview%3Fhl%3Den&hl=en[/url]



If you are running an e-commerce site, you should all ready have an account, it not, now is the time to start getting more traffic to your site.



You will see a box called “Add Site”. Enter your site now and click “OK”. Now you will see the Summary. Notice is says “Verify your ownership”. You need to do this right now. See the gray box a little further down? The one that says “Next Step”? Ok, I want you to click the link “Verify your site”. On the next page the drop down box says “Choose verification method…”. Pick “Add a META tag”. Still with me? Ok, copy the Meta tag being displayed in bold print. Copy everything from < to >. Now you need to edit a file in your shopping cart to put this meta tag into. I want you to find the file this file called meta.tpl and it should be located at skins/yourskin/customer/meta.tpl. Go to the bottom and add the Google Meta Tag.



Once you have uploaded meta.tpl, you can go back to the Google webpage and click the button “Verify”. Now your site should be verified by Google, if not, don’t call me. For the rest of you, you will notice a little yellow alert message that just happens to have a link called “Submit a Sitemap”. Click it ! See the dropdown “Choose type…”? “Choose Add General Web Sitemap” and in box number 3 enter your URL where the sitemap is located. The URL should look like one of these:



[noparse]http://www.mycart.com/index.php?target=google_sitemap[/noparse]

[noparse]http://www.mycart.com/shop/index.php?target=google_sitemap[/noparse]



Then click the button “Add Web Sitemap”. Now you can see status and find out when your site was indexed. Cool uh?

sculptingstudio,



I appreciate this more then you’ll ever know,

google has a tendandcy to kick my website off the server unless I update the sitemap everyfew days.



Problem Solved!

Empty Sitemap

Your Sitemap does not contain any URLs. Please validate and resubmit your Sitemap

[quote name=‘dominos_2004’]Empty Sitemap

Your Sitemap does not contain any URLs. Please validate and resubmit your Sitemap[/QUOTE]Check your steps again:


  1. place the new target in config.php.
  2. google sitemap dispatcher in targets/google_sitemap.php
  3. google sitemap generator in include/customer/google_sitemap.php and include/admin/google_sitemap.php
  4. google meta tag added to skins/yourskin/customer/meta.tpl
  5. submit link [url]http://www.yourcart.com/index.php?target=google_sitemap[/url]



    If you want to see the code run, here is my link to the google sitemap:



    [url]High Speed Carvers, Burs, Sculpting Clays, Fa-Brick, Eggs



    If you place the link above in firefox, you will see the xml displayed.

thanks a lot, i will try this later

Next step maybe to output the site map using SEO if SEO is turned on.

[quote name=‘ETInteractive’]Next step maybe to output the site map using SEO if SEO is turned on.[/QUOTE]Once 1.3.4 is released, this mod can be updated also. It would be a simple matter to fetch the category/product name and formatting the link.

Schema validating with XSV 2.10-1 of 2005/04/22 13:10:49

Schema validator crashed

The maintainers of XSV will be notified, you don’t need to send mail about this unless you have extra information to provide. If there are Schema errors reported below, try correcting them and re-running the validation.



Target:



Last Modified: Fri, 13 Oct 2006 00:19:43 GMT

Server: Apache/1.3.37 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.4.3 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.28 OpenSSL/0.9.7a)

The target was not assessed



--------------------------------------------------------------------------------



Low-level XML well-formedness and/or validity processing output

[quote name=‘dominos_2004’]Schema validator crashed

[url]http://www.indymart.net/index.php?target=google_sitemap[/url][/QUOTE]When I enter your url, I don’t see any output. That would explain the validator crash, nothing to valid.

[quote name=‘sculptingstudio’]When I enter your url, I don’t see any output. That would explain the validator crash, nothing to valid.[/QUOTE]



I understand that, but was installed exactly per your instractions, and no result, just blank page:

[quote name=‘dominos_2004’]so what to do?[/QUOTE]Any errors in your errorlog? Also, if you have memberships set to something other than all, you might try entering the appropriate number of just remove this from the query in google_sitemap.php: membership_id=0

[quote name=‘sculptingstudio’]Any errors in your errorlog? Also, if you have memberships set to something other than all, you might try entering the appropriate number of just remove this from the query in google_sitemap.php: membership_id=0[/QUOTE]



I was remove membership_id=0 but no luck?

[quote name=‘dominos_2004’]I was remove membership_id=0 but no luck?[/QUOTE]Check the Errorlog to see what is happening.

No errors related to google site map

[quote name=‘dominos_2004’]No errors related to google site map[/QUOTE]I just looked at your http response header. My code isn’t being executed. Check the $script_targets to make sure google_sitemap is included and the php files are in the correct folders. In index.php the code that includes the file is:



```php //

// Include target script from $script_targets array

//

if (file_exists(@$script_targets[$target])) {

include $script_targets[$target];

} else {

fn_set_exception(‘no_page’);

} ```



If you change include to require, it will produce an error if the target isn’t found:

```php //

// Include target script from $script_targets array

//

if (file_exists(@$script_targets[$target])) {

require $script_targets[$target];

} else {

fn_set_exception(‘no_page’);

} ```

[quote name=‘sculptingstudio’]I just looked at your http response header. My code isn’t being executed. Check the $script_targets to make sure google_sitemap is included and the php files are in the correct folders. In index.php the code that includes the file is:



```php //

// Include target script from $script_targets array

//

if (file_exists(@$script_targets[$target])) {

include $script_targets[$target];

} else {

fn_set_exception(‘no_page’);

} ```



If you change include to require, it will produce an error if the target isn’t found:

```php //

// Include target script from $script_targets array

//

if (file_exists(@$script_targets[$target])) {

require $script_targets[$target];

} else {

fn_set_exception(‘no_page’);

} ```[/QUOTE]



This is my index.php file no changes:


/******************************************************************************
* *
* Copyright (c) 2004-2005 CS-Cart.com. All rights reserved. *
* *
*******************************************************************************
* *
* CS-Cart is commercial software, only users who have purchased a valid *
* license through [url]https://www.cs-cart.com/[/url] and accept to the terms of this *
* License Agreement can install this product. *
* *
*******************************************************************************
* THIS CS-CART SHOP END-USER LICENSE AGREEMENT IS A LEGAL AGREEMENT BETWEEN *
* YOU AND YOUR COMPANY (COLLECTIVELY, "YOU") AND CS-CART.COM (HEREINAFTER *
* REFERRED TO AS "THE AUTHOR") FOR THE SOFTWARE PRODUCT IDENTIFIED ABOVE, *
* WHICH INCLUDES COMPUTER SOFTWARE AND MAY INCLUDE ASSOCIATED MEDIA, PRINTED *
* MATERIALS, AND "ONLINE" OR ELECTRONIC DOCUMENTATION (COLLECTIVELY, THE *
* "SOFTWARE"). BY USING THE SOFTWARE, YOU SIGNIFY YOUR AGREEMENT TO ALL *
* TERMS, CONDITIONS, AND NOTICES CONTAINED OR REFERENCED HEREIN. IF YOU ARE *
* NOT WILLING TO BE BOUND BY THIS AGREEMENT, DO NOT INSTALL OR USE THE *
* SOFTWARE. *
* *
* PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" *
* FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE *
* AT THE FOLLOWING URL: [url]https://www.cs-cart.com/license.html[/url] *
******************************************************************************/

//
// $Id: index.php 1609 2006-04-28 13:00:38Z zeke $
//

//error_reporting(E_ALL);

DEFINE ('AREA', 'C');
DEFINE ('AREA_NAME' ,'customer');

require './prepare.php';
if (!empty($html_catalog)) {
define ('NO_SESSION', true);
}
require './init.php';

if (!empty($settings['General']['store_access_key'])) {
sess_register('store_access_key');
if (!empty($_GET['store_access_key'])) {
$store_access_key = $_GET['store_access_key'];
}
if ($store_access_key != $settings['General']['store_access_key']) {
fn_redirect('store_closed.html');
}
}
// Converting script vars to use in HTML catalog
if (!empty($html_catalog)) {
$index_script = $cscart_host_dir . '/' . $customer_index;
$image_index = $cscart_host_dir . '/' . $image_index;
// Disable ajax pagination during html catalog generation
$settings['Appearance']['customer_ajax_based_pagination'] = 'N';
$smarty->assign('image_index', $image_index);
} else {
$index_script = $customer_index;
}

//
// Common includes
//
include $common_dir.'customer_common.php';

//

// fn_add_breadcrumb(fn_get_lang_var('home'), $index_script);

//
if (empty($target)) {
$target = 'index';
}

//
// Include target script from $script_targets array
//
if (file_exists(@$script_targets[$target])) {
include $script_targets[$target];
} else {
fn_set_exception('no_page');
}

$smarty->assign('index_script', $index_script);

fn_show_template('index.tpl',$smarty, true);
?>

---------------------------------------------

public_html/targets/google_sitemap.php
public_html/include/admin/google_sitemap.php
public_html/include/customer/google_sitemap.php

[quote name=‘dominos_2004’]This is my index.php file no changes



public_html/targets/google_sitemap.php

public_html/include/admin/google_sitemap.php

public_html/include/customer/google_sitemap.php[/QUOTE]



Assuming the path is correct, this is what is in each file from my first post in this thread.



public_html/config.php should have the code added from section 1.

public_html/targets/google_sitemap.php should have the code from section 2.

public_html/include/admin/google_sitemap.php should have the code from section 3.

public_html/include/customer/google_sitemap.php should have the code from section 3.

[quote name=‘sculptingstudio’]Assuming the path is correct, this is what is in each file from my first post in this thread.



public_html/config.php should have the code added from section 1.

public_html/targets/google_sitemap.php should have the code from section 2.

public_html/include/admin/google_sitemap.php should have the code from section 3.

public_html/include/customer/google_sitemap.php should have the code from section 3.[/QUOTE]



Exactly per your instraction.



But not work!

[quote name=‘dominos_2004’]Exactly per your instraction.



But not work![/QUOTE]Without an error, I can’t go any further.