Jump to content
thalhah

Sitemap XML for WHMCS Knowledgebase

Recommended Posts

Hi, I create my own sitemap.xml for WHMCS Knowledgebase. here's the code.

 

<?php 

//  #######################  SET WHMCS ENVIRONMENT  ########################
   use WHMCS\ClientArea;
   define('CLIENTAREA', true);
   require_once("init.php");
   require_once("includes/functions.php");
   require_once("includes/clientareafunctions.php");

//  #########################  CONNECT TO DATABASE  ########################
   $db = mysqli_connect($db_host, $db_username, $db_password, $db_name);
   if (mysqli_connect_errno())
   {
       echo "Failed to connect to Database: " . mysqli_connect_error();
   }

$sql_whmcs = mysqli_query($db,"SELECT * FROM tblconfiguration WHERE setting='SystemURL' LIMIT 1"); 
$rlt_whmcs = mysqli_fetch_array($sql_whmcs);
$CFG["siteurl"] = substr($rlt_whmcs["value"], 0, -1);

header('Content-Type: application/xml; charset=utf-8');
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n"; 

$result = mysqli_query($db,"SELECT * FROM tblknowledgebase"); 
while ($data = mysqli_fetch_array($result)) { 
$title = str_replace(array(' ','/'), '-', $data['title']);    
$title = str_replace(array('?','.','[',']','"'), '', $title); 
echo '<url>'."\n"; 
echo '<loc>'.$CFG["siteurl"].'/knowledgebase/'.$data['id'].'/'.$title.'.html'.'</loc>'."\n"; 
echo '</url>'."\n";     
}//while 

echo '</urlset>'."\n"; 
?>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated