MyBB Community Forums

Full Version: Copy forum
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, is there any way to copy an entire forum substructure. I have fora which form a tree structure as the same generic areas are covered for each section. When I create a new section it would be good to copy the entire structure from the parent down thru the child levels.

Thanks! Gerry.
No need to use a different size and colour, we can read regular text just fine.

I don't think you can do what you want, I think the copying feature is to copy settings and permissions, not actual forums themselves.
Thanks for that. Nothing intended re size & colour of the post.

Is there anything you could suggest that may help with this? I appreciate this forum does not cover 3rd party code but any suggestions would be appreciated.

Gerry
I don't think there is a way of doing it, there's no plugin for it that I've ever heard of and it can't really be done via SQL either.

You can request a plugin if you want to.
I got it working by running a sql backup of the structure I wanted to copy then resetting the reference links before running a sql insert into the forms table. I still have to reref the links but i have 4 layer structure used for product/service support so it is worth it.

Thanks for your help and prompt responses.

Gerry.
I need to do this also. Can I just upload the tree to the "Forums" table? Or do I have to worry about other tables?

I tried a manual addition in myPhpAdmin, and it isn't working. I assume that "resetting the reference links" is a missing step, but I have no idea to what you are referring...

I think I can generate the forums with a script, then copy them into Excel, then Insert them into the Forums table.

In my testing with manual record insertion in myPhpAdmin, the forums show the correct tree structure to the user, but not in the admin CP.

Looks like running the "Recount & rebuild" > "Rebuild Thread Counters" forced the index to fix itself though...
I use an installation of the forum as a support desk for some clients which is why I need to have the same tree structure repeated per client.

I created a mysql backup of the mybb14_forums table and removed the create table sql statement which left me with the insert into command which recreates the entire forum structure. e.g.

INSERT INTO mybb14_forums (fid, name, description, linkto, type, pid, parentlist, disporder, active, open, threads, posts, lastpost, lastposter, lastposteruid, lastposttid, lastpostsubject, allowhtml, allowmycode, allowsmilies, allowimgcode, allowpicons, allowtratings, status, usepostcounts, password, showinjump, modposts, modthreads, mod_edit_posts, modattachments, style, overridestyle, rulestype, rulestitle, rules, unapprovedthreads, unapprovedposts, defaultdatecut, defaultsortby, defaultsortorder) VALUES (1, '/Contractor Information System & Support', '', '', 'c', 0, '1', 1, 1, 1, 0, 0, 0, '', 0, 0, '', 1, 1, 1, 1, 1, 1, 1, 1, '', 1, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, '', ''),
(2, 'Client support desk', '', '', 'f', 1, '1,2', 1, 1, 1, 2, 2, 1234188279, 'GerryK', 1, 2, 'Hi', 0, 1, 1, 1, 1, 1, 1, 1, '', 1, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, '', ''),
(49, 'Purchase Orders', '', '', 'f', 33, '1,2,29,30,33,49', 1, 1, 1, 0, 0, 0, '', 0, 0, '', 0, 1, 1, 1, 1, 1, 1, 1, '', 1, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, '', '')

etc.


The key field is the parentlist field which states the link between the forum and the entire tree. To copy an entire tree structure modify the sql statement to contain only the branch and sub-branches that you want to copy. Change the forum ID (fid) to a new, not curently used number for each sub forum and rereference the parentlist field for each forum.

Paste the new code into phpmyadmin and run it. There is no need to rebuild as the new structure will be created from the fid and parentlist fields.

It took me a while to work this thru but afer a few goes it only takes a few minutes per copy and it does work.
I'll add a brief description of what I've done as well, in case it helps someone down the road.

I generate the fields with a VBA script in Microsoft Access (because that's what I'm comfortable with). I copy the records to Excel, delete the header row, fill down on the extra fields that I didn't generate in Access and then export to a .cvs file.

In myPhpAdmin, I Import, changing the " ; " separator to a " , ", specify the file, "replace table data with file", "CSV using LOAD DATA", and paste the column names (several ways to get these, your method above is much easier than the way I used.
Thanks for the info. I am ok with MySQL & Phpmyadmin and tried to keep the solution within the system.

I think as long as it works it is a good solution. I am surprised that there are only a few posts about this as I would have thought copying an entire branch would be a common issue.

Anyway - have a good one!