Joomla!
http://forum.joomla.org/

How To Import Sections and Categories?
http://forum.joomla.org/viewtopic.php?f=34&t=134453
Page 1 of 1

Author:  Pastor Dan [ Wed Jan 24, 2007 1:20 pm ]
Post subject:  How To Import Sections and Categories?

In setting up a new Joomla site, I would like to import a large number of sections and categories without tediously entering them one by one manually via the GUI. Ideally, the solution would be to import a csv file into the database in such a way the the IDs automatically increment. In searching the forum, I have been unable to locate a solution. Does anyone know how to do this?

Author:  pe7er [ Wed Jan 24, 2007 2:19 pm ]
Post subject:  Re: How To Import Sections and Categories?

The ID is autoincrement, isn't it? Could you give all the section records that you are about to import a 0 as ID?

Another method: export the current jos_sections as CSV, import that in a spreadsheet.
Add the new records and make sure that the fields do correspondent with the original ones.
Copy the empty fields with the values of the original fields.
& fill the IDs with new (increasing) values.
Import the new records as CSV.

Author:  Pastor Dan [ Wed Jan 24, 2007 5:36 pm ]
Post subject:  Re: How To Import Sections and Categories?

Thanks for the info. I now realize this is very simple if you know what to do. Here's what I did to get it to work for those who don't know much about MySQL, like me.

1. Export the table jos_sections from the database using phpMyAdmin. I exported it with the options csv for Excel and include field names (so I knew what was going on).
2. Open the file in Excel and based on the structure add new lines setting id as zero. The basic elements to change are of course the title, name and possibly a description. Remove the previously existing sections and the field names row and save as csv file.
3. Back in phpMyAdmin, import your csv file into the jos_sections table with format csv and fields terminated by comma. Leave other settings the same.
4. This adds your new sections and auto increments the id.
5. Repeat the process for jos_categories, making sure that you put the correct section numbers in for your new categories.

You should be able to add a very large number of sections and categories relatively painlessly this way.

Author:  Pastor Dan [ Fri Feb 09, 2007 8:18 pm ]
Post subject:  Re: How To Import Sections and Categories?

The above procedure also works to import content items from an Excel csv file directly into the database as well, except when you have double quotes in the content (from html code for example). Even though the double quotes are correctly escaped by another double quote in the Excel csv file, you get an error when trying to import with phpMyAdmin. I think this must be a bug in the importer.

Here is the simple solution. Import your csv file with format "csv using LOAD DATA" rather than format "csv" as indicated above, leaving all other instructions the same. The content with double quotes is correctly imported. I am using PHPmyadmin 2.8.2.4.

Author:  pe7er [ Fri Feb 09, 2007 8:37 pm ]
Post subject:  Re: How To Import Sections and Categories?

Thanks for sharing that usefull info!

PS: Could you please mark your first message in this thread as "solved" ?
(Modify the first message and choose the Message Icon [solved]).
This way the list of messages shows that the question was solved, and other users can benefit from it.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/