Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Simple Sitemap Script

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 10-08-2007, 05:48 AM
 
hockeyshare hockeyshare is offline
 

Newbie
  
Join Date: Apr 2007
Posts: 4
 

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

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>
__________________
http://www.hockeyshare.com

Version 4.1.8
Reply With Quote
  #2  
Old 12-04-2007, 05:29 PM
 
weckie weckie is offline
 

eXpert
  
Join Date: Feb 2005
Location: Netherlands
Posts: 220
 

Default Re: Simple Sitemap Script

Ok. And what can one do with it ???

(i am a nerd
__________________
Herman Steijn

Using: X-cart 4.5.4
AT: http://www.weckonline.com LIVE
Reply With Quote
  #3  
Old 12-08-2007, 04:47 PM
  ShishaPipeUK's Avatar 
ShishaPipeUK ShishaPipeUK is offline
 

Senior Member
  
Join Date: Jul 2005
Location: London, England.
Posts: 118
 

Default 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
__________________
Apache/2.0.55 (Red Hat) & MYSQL Server: 5.0.24
PERL: 5.008005 / PHP: 4.4.4 - 4.3.1 X-CART

Shop carts at
http://www.nightscene.co.uk/shop/home.php
http://www.theshisha.net/shopcart/home.php
http://www.system-maintenance.com/maint/home.php
http://www.tabac4u.com
Reply With Quote
  #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
  #5  
Old 02-01-2008, 08:12 PM
  imexhouse's Avatar 
imexhouse imexhouse is offline
 

eXpert
  
Join Date: May 2006
Location: Canada
Posts: 377
 

Default Re: Simple Sitemap Script

Shisha,
That link to your site_map.php is dead. Error 404.
__________________
Jack@AquasanaCA
X-CART GOLD 4.0.19 Live
DSEFU, AOM, ezCheckout, ezUpsell, ezRecommends, RememberMe, RememberAnonCarts
AquasanaCanada.com - Aquasana╝ - #1 Rated Water Filters in America!
X-CART GOLD 4.4.5 Live
CDSEO Pro v. 1.8.4
AquasanaMontreal.com
Aquasana╝ & Rhino Water Filtration Systems
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:24 AM.

   

 
X-Cart forums © 2001-2020