Page 1 of 1

FAQ: Duplicating Modules, Components, and Mambots

Posted: Fri Sep 09, 2005 7:47 am
by ¥
Mambo has a built-in feature for duplicating modules - but duplicating components and associated modules is a tad bit trickier.

Now I have zero coding experience - but this process has worked in the past for me.

First, you'll need a couple of tools:

1) A robust text editor, capable of searching and replacing through an entire folder and subfolders recursively.

2) A robust file renamer, for renaming files.

Now you need to open the .xml installer file (in your text editor) included with the add-on. When you look through it, you'll see:

1) The name of the component.
2) The database prefixes and tables used by the component.

And this is where things become "dynamic."  :P But don't worry - it's not really that hard.

The GOAL is to make the SMALLEST possible change in both the name of the component AND the table prefix in order to create a NEW copy of the component that acts independently of the old component.

So try three letters. Find three letters in the table prefix and three letters in the name of the component, then search and replace them with a letter sequence that wouldn't commonly occur. Say you're replacing 'ext' for the extcalendar component. Replace 'ext' with 'xkx' for instance.

Now, after you've searched and replaced 'ext' with 'xkx', you'll want to slap yourself on the head. You just replaced the common programming term 'next' with 'nxkx' - and that's just gonna reak all kinda havoc.

But you already KNOW that - so you go back then and replace 'nxkx' with 'next'. See how it works? You screw up, then you go back and fix your mistakes :)

Okay, so you've replaced 'ext' with 'xkx' throughout the entire folder. Before you make your next move, you'll need to use a batch file renamer to do the same to all of the files within the component's file structure. Why? Because the component will be calling files that don't exist otherwise.

So hey - you're almost done. Now you zip the file back up and upload it with Mambo's component uploader.

If the uploader fails, it will tell you which files you forgot to rename :)

Then you can run the component - and the PHP errors will let you know if you screwed up anywhere else :) They'll actually tell you the line numbers, etc.

If you screwed up, then it's back to the drawing board - and you'll need to start with a different sequence of letters for the search and replace. But obviously, start with a copy of the ORIGINAL component folder structure - not the one you just screwed up.

Now this might all SOUND like it takes a horribly long time - but it really only takes about 5 minutes, tops. So you can screw up a few times, and still be way ahead of the game.

And finally, xkx is a horrible name for a component. So, after you're done installing and testing to make sure it works, you're free sailing all the way home.

Just search and replace for 'xkx' with something that seems normal :) - and you've got a shiny new duplicated component, or module, or mambot.

And finally, because I didn't want to make this sound even more difficult than it already sounds. Trust me - it SOUNDS a LOT harder than it actually is. Here's a couple more things:

Use CASE-SENSITIVE search and replace. In the case of replacing 'ext' with 'xkx', you'd search and replace for all variations - the most common being 'Ext', 'ext', and 'EXT'. If you don't do that, you're likely to run into problems. Also ALL search and replace executions should take place through the ENTIRE folder structure for the component or other add-on, NOT just the installation xml file. The xml file is the KEY to this whole process, as it will contain EVERY pattern that must be changed - if it's not in the xml file, it doesn't need to be changed.

ALSO: If you're running into problems with letter sequences like 'ext' - I had one that used 'dir' for instance - remember that you ONLY need to change the component NAME and the table prefixes. Table prefixes almost always end with _ - so rather than replacing ext, try ext_. Again, it sounds like a pain - but it's not really that hard. And once you get the swing of it, you'll be duplicating whatever you like, whenever you like.

Typing a sequence of 3 letters into a robust text editor and having it search and replace through an entire folder takes all of about 3 nanoseconds. It's blistering fast. So again, you can screw up a few times, and still probably pull off a perfect duplicate in less than 30 minutes.

Hope that helps. And if the gurus can correct me where I might have led people astray, PLEASE let 'em know.

Re: FAQ: Duplicating Modules, Components, and Mambots

Posted: Wed May 09, 2007 6:24 am
by jbrowdy
This sounded great, so I painstakingly tried to duplicate a mambot- and every time I install it, it makes my site disappear.  Site reappears when mambot is uninstalled (the copied version).

Any hints out there?

Re: FAQ: Duplicating Modules, Components, and Mambots

Posted: Mon May 14, 2007 8:14 am
by mcsmom
Can you explain why you would want two copies of a mambot?

Re: FAQ: Duplicating Modules, Components, and Mambots

Posted: Mon May 14, 2007 12:11 pm
by jbrowdy
Sure.  I discovered a few great mambots- contentbymail and another similar bot that allow one to email content to the website.  The other one (blanking on the name right now) even allows you to send images.  You select the section and category id's where you want the content to end up.  So, I wanted to create a few copies of the bot, with a few different email addresses so that you can send content to a few different section and cat id's.  Make sense?

Re: FAQ: Duplicating Modules, Components, and Mambots

Posted: Mon May 14, 2007 7:30 pm
by mcsmom
Well, in my experience mambots are a lot more complicated than modules etc. You have to pay attention to what order you load them in and you there are a lot of little details you need to be careful about.

Have you read the docs?

http://help.joomla.org/content/category/12/113/125/

is useful.

Re: FAQ: Duplicating Modules, Components, and Mambots

Posted: Mon May 14, 2007 8:49 pm
by jbrowdy
I'll take a look, but I think you're right.  At present the bot I'd like to dup is acting up.  Don't know why?  It's called MaMmoblog