Change from full url to not, now need to fix the data

6 posts by 3 authors in: Forums > CMS Builder
Last Post: January 8, 2010   (RSS)

Re: [garyhoffmann] Change from full url to not, now need to fix the data

By Chris - January 7, 2010

Hi Gary,

That's not an easy problem to fix. The simple solution, of course, is to recreate all your records and uploads -- but that may be ridiculously time-consuming. :(

A more complicated solution would be to write a PHP script which scans through your records with a regular expression, updating URLs it finds. If you can give me some examples of fields which need to be changed (and what they should be changed to), as well as a list of fields, I could get you started with a script and a regexp. Note that this approach might involve lots of backups, testing, and back-and-forth.

Alternately, we could fix this for you through consulting. Please let me know if this is something you might be interested in.

I hope this helps!
All the best,
Chris

Re: [chris] Change from full url to not, now need to fix the data

By Damon - January 7, 2010

Another option is to backup your database, download it, open your database in a text editor and carefully do a search and replace. Then upload it again and restore.

Make sure you keep and back up of your backup!
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Damon] Change from full url to not, now need to fix the data

By Chris - January 7, 2010

Wow, that's much simpler! Kudos, Damon!
All the best,
Chris

Re: [chris] Change from full url to not, now need to fix the data

Thank you for replying. I may have come up with a code-based alternative to scan the content fields before trying to echo them out. Still working through it, but this may be the answer as nothing needs to change in the data and this can work for other things such as this.

In my case, I'm worried about IMG tags generally. So, I can scan with something like this (in pseudo code):

$myvar = $record['content']
replace_within_string("http://dev.domain.com/cmsAdmin","/cmsAdmin");

replace_within_string would do some regular expression handling.

Now, if something happens, where dev.domain.com needs to become my.new.domain someday, I can use the same code without making a user change their data.

Then, finally, once the replace_within_string is done, I would echo out the fixed string...something like:

<?php echo mydatafix($record['content']) ?>

I would wrap the above commands into the mydatafix function. That should solve the issue, but don't know for sure if it will work.

It's all within wysiwyg fields, so this "should" work

Re: [garyhoffmann] Change from full url to not, now need to fix the data

By Chris - January 8, 2010

Best of luck! Please let us know how it goes. :)
All the best,
Chris