First Contrib to the greater good.. Any Suggestions, please let me know.
This is strongly based on a small script coded by Paul, noted here->
http://modxcms.com/forums/index.php/topic,3656.0.html
It has been modded to import from an XOOPS DB on the same server. So other X-XOOPers jump in, the water is warm.
(I promise not because of something I did)
Cheers,
Gregg
<?php
//XOOPS News Story Migration (XOOPS-->ModX)
//Hacked together by: [email protected]
// -- forum id:romdg
//based on a import script written by [email protected]
//his forum post (http://modxcms.com/forums/index.php/topic,3656.0.html)
// Special notes: Once you import the news you will still need to go back and modify
// -- all those wonderful xoop smarty tags, ie. [url][/url], etc.
// -- Replace the DB**** parameters with correct values
// -- My XOOPS News Module was Version 1.1.. There may be small variances between versions.
//********************************************
//Set XOOPS Database settings
$MySqlHostnamexoops = "localhost";
$MySqlDatabasexoops = "DBNAME";
$MySqlUsernamexoops = "DBUSER";
$MySqlPasswordxoops = "DBPASSWORD";
//Make Database connection
$dblink=MYSQL_CONNECT($MySqlHostnamexoops, $MySqlUsernamexoops, $MySqlPasswordxoops) OR DIE("Unable to connect to database");
@mysql_select_db("$MySqlDatabasexoops") or die( "Unable to select database");
$query = 'SELECT * FROM xoops_stories';
$results = mysql_query($query);
//Set the start value for the modx menu index. See what the last index value was set and add 1.
$menuindex = 26;
while($rec = mysql_fetch_object($results))
{
$timestamp = $rec->created;
$introtext = '';
$content = '';
if($rec->hometext && $rec->bodytext)
{
$introtext = $rec->hometext;
$content = $introtext . $rec->bodytext;
}
else
{
$content = $rec->hometext;
}
$q = 'INSERT INTO modx_site_content';
$q .= '(type,contentType,pagetitle,longtitle,alias,published,pub_date,parent,isfolder,introtext,content,richtext,template,menuIndex,searchable,cacheable,createdby,createdon,editedby,editedon,hidemenu)';
$q .= 'VALUES(';
$q .= quote('document') . ',';//type
$q .= quote('text/html') . ',';//contentType
$q .= quote($rec->title) . ',';//pagetitle
$q .= quote($rec->title) . ',';//longtitle
$q .= quote('article-'.$timestamp) . ',';//alias
$q .= '1,';//published
$q .= $timestamp . ',';//pub_date
$q .= '9,';//parent -- Set to the id of your News/Blog Folder
$q .= '0,';//isfolder
$q .= quote($introtext) . ',';//introtext
$q .= quote($content) . ',';//content
$q .= '1,';//richtext
$q .= '4,';//template -- Same modx template id set on other news stories
$q .= $menuindex++ . ',';//menuIndex -- Document Index in ModX(initial is set above)
$q .= '1,';//searchable(1), not searchable(0)
$q .= '1,';//cacheable(1), not cacheable(0)
$q .= '1,';// createdby -->set to modx news author id
$q .= $timestamp . ',';//createdon
$q .= '1,'; //editedby -->set to modxnews author
$q .= $timestamp . ',';//editedon
$q .= '1,'; //hidemenu (1), show in menu(0)
$q = substr($q, 0, -1);
$q .= ')';
//MODX database info
$MySqlHostnamemodx = "localhost";
$MySqlDatabasemodx = "DBNAME";
$MySqlUsernamemodx = "DBUSER";
$MySqlPasswordmodx = "DBPASSWORD";
//Make Database connection
$dblink1=MYSQL_CONNECT($MySqlHostnamemodx , $MySqlUsernamemodx , $MySqlPasswordmodx ) OR DIE("Unable to connect to database");
@mysql_select_db("$MySqlDatabasemodx ") or die( "Unable to select database");
mysql_query($q) or die(mysql_error() . ' -- ' . $q);
}
function quote($str)
{
$str = str_replace("'", "''", $str);
return "'$str'";
}
?>