X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Simple Sitemap Script (https://forum.x-cart.com/showthread.php?t=34447)

hockeyshare 10-08-2007 05:48 AM

Simple Sitemap Script
 
Here's a simple script to generate a quick sitemap and url list from your x-cart install. This script only does the basic categories and products. I made this one because I was sick of all the other sitemap generators indexing thousands of pages for 50 products. Hope this helps someone. :mrgreen:

PHP Code:

<?php

    
# 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.hockeyshare.com/webstore/';
    
    
#
    # THE REST SHOULD BE FINE - ONLY MODIFY IF YOU KNOW WHAT YOU'RE DOING
    #
    
mysql_connect($mysql_host,$mysql_user,$mysql_pass);
    
mysql_select_db($mysql_db);
    
    
    
$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>


weckie 12-04-2007 05:29 PM

Re: Simple Sitemap Script
 
Ok. And what can one do with it ???

(i am a nerd :)

ShishaPipeUK 12-08-2007 04:47 PM

Re: Simple Sitemap Script
 
Quote:

Originally Posted by weckie
Ok. And what can one do with it ???

(i am a nerd :)


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

Yurij 01-31-2008 07:39 AM

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>


imexhouse 02-01-2008 08:12 PM

Re: Simple Sitemap Script
 
Shisha,
That link to your site_map.php is dead. Error 404.


All times are GMT -8. The time now is 12:36 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.