DeeEmm

Pragmatism in code

Pragmatism in code

Waxing lyrical about life the universe and everything software related since lunchtime 2006.
1 minute reading time (284 words)

Dolphin Tag Converter

If like me, you used the migration tool to transfer your Dolphin 6 based site over to Dolphin 7, you will notice that there are some things that need a little tweaking. One of these things for me was the tags.

On D6 tags could use a space as a delimiter, but on Dolphin 7 the space is ignored, this is to allow multi word tags. What this effectively does is create massive long 'tag words' out of those tags that were entered without using a comma as a delimiter in D6.

The following code reads the tags and splits them up if more than one word is detected. it then deletes the original entry and creates a new entry for each word detected using the original data. Single word tags are ignored

$sql_query = mysql_query("SELECT * FROM `sys_tags`");

while($sql_result = mysql_fetch_array($sql_query))

{

$sTag = $sql_result['Tag'];

$sObjID = $sql_result['ObjID'];

$sType = $sql_result['Type'];

$aTag = explode(" ", $sTag);

if (count($aTag) > 1){

mysql_query("DELETE FROM `sys_tags` WHERE `Tag` = '{$sql_result['Tag']}'");

foreach($aTag as $sNewTag) {

mysql_query("INSERT INTO `sys_tags` (`Tag`, `ObjID`, `Type`, `Date`) VALUES ('$sNewTag', '$sObjID', '$sType', '{$sql_result['Date']}') ") or die(mysql_error());

echo 'new tag ' . $sNewTag . ' created
';

}

}

}

You will need to decide how you deploy the code - I downloaded the sys_tags table from my site and created a test database on my local test server with it, then I simply added a database connection to the above code it and ran it locally. I then uploaded the resultant table back to my sites database.

Please make sure you make a backup before running this script, as once the values have been modified there is no way to go back.

/DM

 

 

Dolphin 7.0.2 Released
Google Chrome for Mac

Related Posts

 

Comments 1

DeeEmm on Friday, 02 July 2010 01:38
This also available as a downloadable MOD from our store - [url]http://www.deeemm.com/store.html?page=shop.product_details&flypage=flypage_no_button.tpl&product_id=18&category_id=5[/url]
Already Registered? Login Here
Guest
Wednesday, 26 September 2018
If you'd like to register, please fill in the username, password and name fields.

Captcha Image