View Single Post
  #4  
Old 01-31-2008, 07:39 AM
  Yurij's Avatar 
Yurij Yurij is offline
Banned
 

X-Adept
  
Join Date: Jan 2008
Posts: 486
 

Default Re: Simple Sitemap Script

Quote:
Originally Posted by ShishaPipeUK
Well if you make a php file with the above code and load it into your root of your x-cart and then call the php script it will give you a URL list and a Sitemap URL Entries for your site.

All you need to do is fill in your site information in the php code:

# MySQL Info
$mysql_host = 'localhost'; # MySQL Host Name
$mysql_user = 'username'; # MySQL Username
$mysql_pass = 'password'; # MySQL Password
$mysql_db = 'database_name'; # MySQL Database

# The Full URL to Your Webstore - INCLUDING THE TRAILING SLASH
$base_url = 'http://www.shishapipe.net/shopcart/';

Once you have done this and then saved the php file, say call it site_map.php and then run this on your site.

You can see an example at http://www.shishapipe.net/shopcart/site_map.php

And if to do so?

PHP Code:
<?php
    
# connect to db and etc.
    
require "./auth.php";

    
# The Full URL to Your Webstore - INCLUDING THE TRAILING SLASH
    
$base_url 'http://www.hockeyshare.com/webstore/';
    
    
#
    # THE REST SHOULD BE FINE - ONLY MODIFY IF YOU KNOW WHAT YOU'RE DOING
    #
    
    
    
$gs '';
    
$txt '';
    
$sql "SELECT productid FROM xcart_products WHERE forsale = 'Y'";
    
$result mysql_query($sql);
    
    while(
$row mysql_fetch_assoc($result)) {
        
$txt .= $base_url.'product.php?productid='.$row['productid']."\n";
        
$gs .= '
<url>
  <loc>'
.$base_url.'product.php?productid='.$row['productid'].'</loc>
  <priority>0.5</priority>
  <lastmod>2007-10-04T09:34:31+00:00</lastmod>
  <changefreq>weekly</changefreq>
</url>'
;
    }
    
    
    
$sql "SELECT categoryid FROM xcart_categories WHERE avail = 'Y'";
    
$result mysql_query($sql);
    while(
$row mysql_fetch_assoc($result)) {
        
$txt .= $base_url.'home.php?cat='.$row['categoryid']."\n";
        
$gs .= '
<url>
  <loc>'
.$base_url.'home.php?cat='.$row['categoryid'].'</loc>
  <priority>0.5</priority>
  <lastmod>2007-10-04T09:34:31+00:00</lastmod>
  <changefreq>weekly</changefreq>
</url>'
;
    }
    

?>
<b>URL List</b>:<br />
<textarea cols="50" rows="20"><?php echo $txt?></textarea>

<br />
<br />
<b>Sitemap URL Entries</b>: <br />
<textarea cols="50" rows="20"><?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/09/sitemap.xsd">
<?php echo $gs?>
</urlset></textarea>
Reply With Quote