Import-function for Joomla (as a component?)

For Joomla! 1.0 Coding related discussions.
User avatar
Hackwar
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3748
Joined: Fri Sep 16, 2005 8:41 pm
Location: NRW - Germany
Contact:

Import-function for Joomla (as a component?)

Postby Hackwar » Wed Nov 02, 2005 10:14 am

Hi folks,
in reference to this thread, I propose a structure for an import-component. I'm not sure wether I will be able to code something like this myself (not able cause of lack of time and probably experience), but I think it will be worth to discuss.
The idea is to make it as modular as possible, which means in the end, you can import every file to every database-storage target. For example importing an open-office-document into a content-item or a excel-table into a numbering component.
In order to achieve this, the component itself has only a few API-functions (Placing Headings into their respective HTML-tags, reading the xml-file for the target, calling the interpreter-class), everything else is optional stuff.
Just outlining the process:
- Import-component gets called
- different, available target-formats are read from the db, corresponding source-formats are read from the db
- Import-screen gets shown, possibility to choose which component should be the receiver, displays possible input-formats for this component
- user specifies file and upload
- API reads file into buffer and calls interpreter with buffername and profilename.
- Interpreter reads buffer, interprets data according to xml-profile
- API fills db with the variables with the different objects of the chosen component.

In the root folder of the component you find the API, the interface and all classes for importable types, in subfolders you find xml-files that control the API and the interpreter classes. For every component that can import data (it does not do this itself) there is a xml-file with the target-db-tables, structure of these, etc. For every interpreter there has to be a xml-file in that component-folder how to read the file. Only if a target-xml-file and a source-xml-file exist, the interpreter is able to add content to the db. One target-xml, several source-xml (for every supported file-format one) If a dev wants to add support for his component, he just has to write a target-xml and define source-xmls (which would be handled as profiles)
I know this is not very professional how I look at it, but its the way I picture how it can be done. It would also enable several devs to work on this...

Lets see what we can make of it and if I will find time to devote to this project. At the moment I still have to work on ACL and I've got two other ideas I want to realise first, but then... ;)

Comments as allways appreciated
Hackwar
god doesn't play dice with the universe. not after that drunken night with the devil where he lost classical mechanics in a game of craps.

Since the creation of the Internet, the Earth's rotation has been fueled, primarily, by the collective spinning of English teachers in their graves.

emeyer
Joomla! Explorer
Joomla! Explorer
Posts: 315
Joined: Thu Sep 29, 2005 2:37 am
Contact:

Re: Import-function for Joomla (as a component?)

Postby emeyer » Wed Nov 02, 2005 12:30 pm

Well now you find...that's hwat I've been up to!

http://developer.joomla.org/sf/projects/site_import

* Imports a set of web pages into the database as Joomla content items
* If page contains H1 it becomes first content item in a new category in a new section.
* If page contains H2 it becomes first content item in a new category in the same section.
* Creates section blogs and menu modules for each section
* Creates category blogs and submenus for each category
* Creates individual menu items for each page.
* scans each file for relative links to other files being imported and converts them to content item links.
* Note that sections must be present in main menu for advanced SEF to work (menu items must be present but may be unpublished).

Known issues:
* relative links between subdirectories not parsed correctly.
* only imports from local disk drive.
* admin interface limited; does not allow setting blog options
* Images not imported automatically. For images and other files, simply copy them to {root}/images/.. and they will show up correctly.
* It needs to show list of previous import operations and permits bulk deletion. This is otherwise quite time consuming as one must delete items, empty the trashcan, delete menus, delete items from main meu, empty trashcan again, delete categories, delete sections, and delete modules.

Biggest dev problem: for a couple thousand pages this can take several minutes, so I am trying to get an  incremental display working during import. So I try drawing a greyed menu at the top of the page but I can't work out how to do that without redirecting the url which stops the import.

I'd welcome any assistance on this project, or if someone thinks it needs rewriting from scratch, then I humbly indicate, I only have been writing PHP for four weeks ~ sorry my coding skills are somewhat limited. Codwise It's all pretty much in one long routine until I work out exactly the best way to cut it up into sections.

I looked at calling other joomla classes in admin/component but they are not really designed for independent invocation, they are all more geared to supporting UIs, so I ended up making alot of code, it's >1000 lines. 

- Ernest

User avatar
Hackwar
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3748
Joined: Fri Sep 16, 2005 8:41 pm
Location: NRW - Germany
Contact:

Re: Import-function for Joomla (as a component?)

Postby Hackwar » Wed Nov 02, 2005 12:41 pm

As I said, I'm a bit short of time at the moment (aren't we all?), but I would do this with you or based on your work as soon as I've completed ACL (I think its MUCH more needed at the moment.).
My idea aimed at the possibility to import not only HTML but OpenOffice-documents, Word-, Excel-, XML- and everything else thats saved in a file. With a modular structure like the one above you could make it possible to create content-items, but also entrys for a calendar component. It just has to deliever a XML-file with the parameters for the import function. Something like which table to put it into, which fields this table consists of, etc. For the files-to-be-imported, you can make a interpreter, which then is controlled by a xml-file and for example searches for special charachters or strings in the file and uses the next x chars for the title for example. Something like a Templating engine for importing data.
god doesn't play dice with the universe. not after that drunken night with the devil where he lost classical mechanics in a game of craps.

Since the creation of the Internet, the Earth's rotation has been fueled, primarily, by the collective spinning of English teachers in their graves.

emeyer
Joomla! Explorer
Joomla! Explorer
Posts: 315
Joined: Thu Sep 29, 2005 2:37 am
Contact:

Re: Import-function for Joomla (as a component?)

Postby emeyer » Wed Nov 02, 2005 1:18 pm

Well that may be the same or different. What I found for content, at least, it was very time consuming to create all the sections, categories, and menu items, so much so that performing the raw import itself almost became secondary. Also to get the menu appearance I wanted I had to create separate menus for each section. And after the import it sets menu item visibility so that menus nest properly. This means the admin interface also should provide settings for default menu settings for each imported item, as well as settings for the imported items themselves. In addition, to display constent sections one wants blogs, so that also means the admin interface ideally sets:

* item params
* item ordering
* category and section ordering
* placement of section links in main menu
* menu module params
* menu item params
* section blog params
* category blog params

I'm finding the length of this list somewhat daunting, especially as the admin interface is due for a total redesign shortly!

ludootje
Joomla! Guru
Joomla! Guru
Posts: 610
Joined: Thu Sep 01, 2005 12:22 pm

Re: Import-function for Joomla (as a component?)

Postby ludootje » Wed Nov 02, 2005 7:11 pm

emeyer wrote:Well now you find...that's hwat I've been up to!

* Imports a set of web pages into the database as Joomla content items
* If page contains H1 it becomes first content item in a new category in a new section.
* If page contains H2 it becomes first content item in a new category in the same section.
* Creates section blogs and menu modules for each section
* Creates category blogs and submenus for each category
* Creates individual menu items for each page.
* scans each file for relative links to other files being imported and converts them to content item links.
* Note that sections must be present in main menu for advanced SEF to work (menu items must be present but may be unpublished).




Hi Ernest,

Thanks for your collaboration in this "bulk import / export" component. I have my doubts, however, regarding the assumptions you make. I have a couple of thousand "old" files, ready to be imported in Mambo / Joomla, but I don't see any system in the usage of

and

tags... If these tags occur, they are not related to the title of the article. I feel it would make much more sense to give the user the option to choose what he wants to be interpreted as the title - and also to give him the option to fill in a title while importing his stuff.

I also don't think it makes a lot of sense to have sections and categories generated, at least not at all in my case. The contents of my old files is very varied, and having them stuffed in some automatically generated category or having them show up in my menu would be more of a nuisance than a help.

To me, the main thing an import component should do, is read all (or a selection of) the files of a certain folder on my harddisk, put them in a list in the Mambo backend, and give me the option to a) fill in the title, b) select a section from a pulldown list, c) select a category from a pulldown list, and probably d) a space to fill in some keywords. So something like this:

-------------------------------------------------------------
Mark the files you want to import:
o  File001.htm            Fill in title              section pulldown list                category pulldown list      Fill in keywords
o  Yourfile.txt              Fill in title              section pulldown list                category pulldown list      Fill in keywords
o  Yetanotherfile.htm  Fill in title              section pulldown list                category pulldown list      Fill in keywords

O  Import              O Cancel
--------------------------------------------------------------

I really wouldn't go too far in automating the generation of categories and sections, or if you do, give the user the option to not use it and fill everything in manually... Automation makes sense, but it should not become an obstacle. In my situation, which has to do with running a magazine which has dozens of new articles every week, it would definitely not make sense to have all imported articles automatically added to my menu.

Don't let this discourage you, however. I feel you are working on a tremendously useful component, and I can't wait to see it completed.

Ludo


User avatar
eyezberg
Joomla! Hero
Joomla! Hero
Posts: 2860
Joined: Thu Aug 25, 2005 5:48 pm
Location: Geneva mostly
Contact:

Re: Import-function for Joomla (as a component?)

Postby eyezberg » Wed Nov 02, 2005 7:41 pm

To the "section pulldown", I'd add a "none" option, which then inserts the item as static content.
Sometimes one pays most for the things one gets for nothing.
The important thing is not to stop questioning. Curiosity has its own reason for existing. AE
http://joomla15.[URL banned].com for J! 1.5 screenshots
http://www.eyezberg.com

ludootje
Joomla! Guru
Joomla! Guru
Posts: 610
Joined: Thu Sep 01, 2005 12:22 pm

Re: Import-function for Joomla (as a component?)

Postby ludootje » Wed Nov 02, 2005 8:29 pm

eyezberg wrote:To the "section pulldown", I'd add a "none" option, which then inserts the item as static content.


OK, that would make sense, Eyezberg: so, either select a section from a pulldown list, or else have your imported text turned into static content. Good idea. As long as the importing component doesn't force the user to subject himself to some automated but most likely not wanted "solution". For me, the thing that I want to be automated the most, is to have a list of files appear in my backend, and a corresponding number of fill-up-the-blanks.

Ludo

emeyer
Joomla! Explorer
Joomla! Explorer
Posts: 315
Joined: Thu Sep 29, 2005 2:37 am
Contact:

Re: Import-function for Joomla (as a component?)

Postby emeyer » Thu Nov 03, 2005 2:19 am

That may be the case for folks with a large number of varied files. Suppose on th eother hand I want to import the phpdocumentator output as joomla items. I don't want to sit there assigning things for a thousand files manually. Same issue for javadoc et ilk.

The H1/H2 division was for me at least pretty arbitrary, it was what I made FrameMaker dump out for my 2000 source files for book and chapter titles. Then I want it at least in categories so I can easily restrict searches, and by putting it in categories and sections I can make multipage blogs and tables.

The title text is actually taken from the TITLE tag in the head, or the filename if not present. But this is another area that can get complicated because you may want short titles for menus, longer titles for bookmarks.

Perhaps the difference is that I am looking at "SITE import" with emphasis on SITE, implying many similar files resulting in large metastructures of categorized items....As opposed to "IMPORT file" with emphasis on IMPORT, implying many different kinds of supported files and options

User avatar
Hackwar
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3748
Joined: Fri Sep 16, 2005 8:41 pm
Location: NRW - Germany
Contact:

Re: Import-function for Joomla (as a component?)

Postby Hackwar » Thu Nov 03, 2005 5:29 am

With the component I've got in mind, you could make both, its just a question of the import-profile
god doesn't play dice with the universe. not after that drunken night with the devil where he lost classical mechanics in a game of craps.

Since the creation of the Internet, the Earth's rotation has been fueled, primarily, by the collective spinning of English teachers in their graves.

ludootje
Joomla! Guru
Joomla! Guru
Posts: 610
Joined: Thu Sep 01, 2005 12:22 pm

Re: Import-function for Joomla (as a component?)

Postby ludootje » Thu Nov 03, 2005 6:49 am

Hackwar wrote:With the component I've got in mind, you could make both, its just a question of the import-profile


You're really making me too curious and anxious, Hackwar!! I do hope you get the thing going...

By the way, I did some searching in the http://forum.mamboserver.com (I know, it's not Joomla...), looking for "batch" and "bulk" as search terms. Nothing concrete came up (except for a promising but sadly very dead link). The main idea of the responses was "should not be too difficult", "I'll see what I can do" etc. So no real help, but it's not a really new wishlist item, apparently.

Ludo

ludootje
Joomla! Guru
Joomla! Guru
Posts: 610
Joined: Thu Sep 01, 2005 12:22 pm

Re: Import-function for Joomla (as a component?)

Postby ludootje » Thu Nov 03, 2005 6:54 am

emeyer wrote:Well now you find...that's hwat I've been up to!

http://developer.joomla.org/sf/projects/site_import



Hi Ernest,

I tried your site_import component. It came to a stop with an error on an "unknown function", gettnulldate(). I noticed that the result of this function is, well, the "null date", which is to be written in the __content table. In your opinion, would it be dangerous to comment out this function and the line where the result is written away? I wouldn't want to mess up my __content table, but I am also very curious to see the result of your component. What do you think, could I comment it out, or would that be a risk?

Ludo

emeyer
Joomla! Explorer
Joomla! Explorer
Posts: 315
Joined: Thu Sep 29, 2005 2:37 am
Contact:

Re: Import-function for Joomla (as a component?)

Postby emeyer » Thu Nov 03, 2005 11:24 am

This must be a PHP version issue, I was using php 4.4. Yes it can be commented out, if you also comment out

line 613: $rowItem->publish_down = $nullDate;

this is simply setting to hardcoded default '0000-00-00 00:00:00' currently, so unless there are other version errors it should work

- Ernest

User avatar
Hackwar
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3748
Joined: Fri Sep 16, 2005 8:41 pm
Location: NRW - Germany
Contact:

Re: Import-function for Joomla (as a component?)

Postby Hackwar » Thu Nov 03, 2005 12:04 pm

ludootje wrote:You're really making me too curious and anxious, Hackwar!! I do hope you get the thing going...

By the way, I did some searching in the http://forum.mamboserver.com (I know, it's not Joomla...), looking for "batch" and "bulk" as search terms. Nothing concrete came up (except for a promising but sadly very dead link). The main idea of the responses was "should not be too difficult", "I'll see what I can do" etc. So no real help, but it's not a really new wishlist item, apparently.

I am very busy at the moment, which means it could take several month till something would be even remotely presentable and although I've got lots of ideas which form into a relatively good picture of this component, there are still a lot of questions unanswered. You would have to set standards for either the xml-file or the db-tables, you have to get an interpreter engine that reads those formats into php, which is idealy written in php. And at last you have the little task to write an API...
I probably made to much promises all ready, I will first complete the ACL-stuff I started and have progressed fairly far, then I want to write a proof of concept for a timer-API and if it gets accepted, I'll complete it. If this all is done, I'll try to write a component that will be the basis for future import-functions. When its ready, every 3PD who wants to use this feature would have to create his own xml-file on how to import which data into his add-on.

I found something interesting at Drupal (first time I looked there, its probably the better cms, I wonder if I should change ;) ) and if I get to this, I'll ask the author for his expertise...
god doesn't play dice with the universe. not after that drunken night with the devil where he lost classical mechanics in a game of craps.

Since the creation of the Internet, the Earth's rotation has been fueled, primarily, by the collective spinning of English teachers in their graves.

emeyer
Joomla! Explorer
Joomla! Explorer
Posts: 315
Joined: Thu Sep 29, 2005 2:37 am
Contact:

Re: Import-function for Joomla (as a component?)

Postby emeyer » Thu Nov 03, 2005 12:12 pm

Also, original discussion on this topic from earlier last month:

http://forum.joomla.org/index.php/topic,11036.0.html

User avatar
Chris Davenport
Joomla! Ace
Joomla! Ace
Posts: 1383
Joined: Thu Aug 18, 2005 8:57 am
Location: Shrewsbury, Shropshire, United Kingdom

Re: Import-function for Joomla (as a component?)

Postby Chris Davenport » Thu Nov 03, 2005 12:21 pm

ludootje wrote:I tried your site_import component. It came to a stop with an error on an "unknown function", gettnulldate(). I noticed that the result of this function is, well, the "null date", which is to be written in the __content table.

I haven't looked at the code but getNullDate is a function defined in the Joomla database class.  It was implemented in Joomla 1.0.0 onwards so unless you are using Mambo 4.5.2.3 or before, you shouldn't see this error.

Regards,
Chris.
Chris Davenport - Joomla Production Leadership Team

Lion Coppice http://www.lioncoppice.org/
Davenport Technology Services http://www.davenporttechnology.com/

User avatar
pasamio
Joomla! Ace
Joomla! Ace
Posts: 1318
Joined: Thu Aug 18, 2005 9:27 am
Location: San Jose, CA, USA
Contact:

Re: Import-function for Joomla (as a component?)

Postby pasamio » Thu Nov 03, 2005 1:47 pm

Sounds cool, considered using AJAX to report back? or opening a new window and refreshing an image generated from a file, there are a few ways around it...

Sam
Sam Moffatt
Updater, Installer and Authentication Systems
JoomlaCode Backend Systems
Pie.

ludootje
Joomla! Guru
Joomla! Guru
Posts: 610
Joined: Thu Sep 01, 2005 12:22 pm

Re: Import-function for Joomla (as a component?)

Postby ludootje » Thu Nov 03, 2005 5:28 pm

emeyer wrote:This must be a PHP version issue, I was using php 4.4. Yes it can be commented out, if you also comment out

line 613: $rowItem->publish_down = $nullDate;

this is simply setting to hardcoded default '0000-00-00 00:00:00' currently, so unless there are other version errors it should work

- Ernest



Hi Ernest,

I tried using your site import component. As you suggested, I commented out the two lines which contain "nulldate". No problem there.
I then selected a file which I completely stripped of all "frills". I just put

Big stuff

Slightly smaller stuff tags in the text, and wrote the text location in the first text area of your component, with its correct path.
I then indicated which module is running my mainmenu. In my case, that's  mod_dm-t_2-0-1 (I think it's called Tigra Menu or something).
Then I selected the "Location for sections to be in inserted in top main menu: ". I don't know if I did something wrong there, because I just picked one element from the 150 or so which were shown to me and which make up my main menu. I didn't quite understand what this selection list was for, but at least I didn't generate an error by just picking anything.

Then I pushed the magic button: "Import" .........

The result was a bit meager... I got a screen which said: "Processing 0 files  /    Filename ID    /    Submit button", which I pushed, which brought me back to the main screen of my backend. Nothing has happened... * sigh *

Did I do something wrong? I don't think it would be due to the intricacies of the file which I wanted to import, because that was really a barebones .htm file.

Hope you can shed a bit of light...

Ludo

User avatar
pollen8
Joomla! Explorer
Joomla! Explorer
Posts: 350
Joined: Wed Aug 17, 2005 10:32 pm
Location: la Rochelle - France
Contact:

Re: Import-function for Joomla (as a component?)

Postby pollen8 » Fri Nov 04, 2005 1:18 am

I think you might stuggle with the non-open file formats (eg Word) as they're not really designed for parsing. Open Office 2 supports a xml file format I think its called opendoc (??) which might be easier to parse.

For the MS products, and only on MS servers, I beleive you can create some php that would interact with the MS apps, allowing you to possibly convert the files into something more readable, (lol - not word to html tho - cos that's a mess :D)
aka

ludootje
Joomla! Guru
Joomla! Guru
Posts: 610
Joined: Thu Sep 01, 2005 12:22 pm

Re: Import-function for Joomla (as a component?)

Postby ludootje » Fri Nov 04, 2005 7:40 am

At this stage - i.e. before any stage at all  :) - I wouldn't bother too much about  file formats. I for one would be Very Happy if the component could only handle .txt files. Being over-ambitious might not lead to anything in the end. Let's first get the framework of the component together. There are zillions of conversion and text manipulation utiilities available. But there is not one single Mambo / Joomla bulk import component. I think it makes good sense to focus on that first.

Ludo

User avatar
sastian
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Wed Sep 07, 2005 10:26 pm
Location: Chicago
Contact:

Re: Import-function for Joomla (as a component?)

Postby sastian » Fri Nov 04, 2005 7:45 am

HERE HERE!!

i agree whole heartedly.
has anyone inspected the output from something like MT's export feature? if someone wants a file to work with i can produce one.

User avatar
Hackwar
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3748
Joined: Fri Sep 16, 2005 8:41 pm
Location: NRW - Germany
Contact:

Re: Import-function for Joomla (as a component?)

Postby Hackwar » Fri Nov 04, 2005 11:23 am

I think the main-target for this import-component would be to make txt and html interpreters to import the stuff. When that works, everybody else can create an interpreter that fits into the API. Thats the reason for modular. You want to have it import text out of old C64 games? Write your interpreter and 2 xml-files for the whole stuff and your good to go. Joomla just gives you the API, so you just have to fill the values in the variables and tell it for which component you want it and your done.

Hackwar
god doesn't play dice with the universe. not after that drunken night with the devil where he lost classical mechanics in a game of craps.

Since the creation of the Internet, the Earth's rotation has been fueled, primarily, by the collective spinning of English teachers in their graves.

Riverbr
Joomla! Apprentice
Joomla! Apprentice
Posts: 38
Joined: Mon Sep 12, 2005 9:15 pm
Contact:

Re: Import-function for Joomla (as a component?)

Postby Riverbr » Mon Nov 07, 2005 2:13 pm

I'm not much of a coder, so I wanted to clarify something on this component.  This component can only import files with .txt as the extension, as opposed to .html?

I was screwing around with it last night, trying to import .html pages, and I ran into the issue above, where the application sort of "dead ended" back to the main admin page.

emeyer
Joomla! Explorer
Joomla! Explorer
Posts: 315
Joined: Thu Sep 29, 2005 2:37 am
Contact:

Re: Import-function for Joomla (as a component?)

Postby emeyer » Mon Nov 07, 2005 3:39 pm

Hi folks

If you are having problems with joomla import, I can't really help if I can't duplicate your problems. The only other thing I can suggest is making sure the file is in the same disk as joomla. I haaven't tested on different platforms, different dbase versions, different php versoins. If you could post your version info I can have a look at it.

The current version does return to the main page. I have been trying to write dymnamic comments to the Joomla window but it is not readily conducive to such a design. I think it would be better to open a new window for comments.

Regarding bulk import: creating the content items is no problem, but they are pretty useuless without menu links. What do you think would be best for the menu links?

Riverbr
Joomla! Apprentice
Joomla! Apprentice
Posts: 38
Joined: Mon Sep 12, 2005 9:15 pm
Contact:

Re: Import-function for Joomla (as a component?)

Postby Riverbr » Mon Nov 07, 2005 9:25 pm

errrr.  I might be missing the entire premise.  I was treating this as an "upload" component.  Do I have to have the files on the server with Joomla?  I'll try that.  Serves me right for trying to do things at 2 am...

emeyer
Joomla! Explorer
Joomla! Explorer
Posts: 315
Joined: Thu Sep 29, 2005 2:37 am
Contact:

Re: Import-function for Joomla (as a component?)

Postby emeyer » Tue Nov 08, 2005 2:02 am

I'm sorry, I tried putting the instructions in various places, perhaps it should be in the component itself.

This is "import" but as for upload, I would need a Mac and a Unix installation in debug configs for validation. I only have windows xp and as such I can't be sure the files will upload relibably via other methods, so I didn't put any more time into developing such "upload" code. I would certainly welcome any code developers with these or other facilities to assist with the project.

Riverbr
Joomla! Apprentice
Joomla! Apprentice
Posts: 38
Joined: Mon Sep 12, 2005 9:15 pm
Contact:

Re: Import-function for Joomla (as a component?)

Postby Riverbr » Tue Nov 08, 2005 12:29 pm

No need to apologize.  I appreciate all of your efforts (as well as all of the Joomla community's), in getting this and other useful components out to us.

apc
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 222
Joined: Thu Dec 29, 2005 8:17 am
Location: East Yorkshire, UK
Contact:

Re: Import-function for Joomla (as a component?)

Postby apc » Thu Dec 29, 2005 10:05 pm

Hello,

I really am in need of this component having to import many static HTML pages.

I have successfully installed the component and it appears to go through the import process, i.e. Import then Submit.

However, I cannot locate the imported page. Where can I find the page I have imported for inclusion in my Joomla content?

Thanks for a really useful component.

Best regards.

SleepRequired
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Fri Mar 09, 2007 4:27 am

Re: Import-function for Joomla (as a component?)

Postby SleepRequired » Fri Mar 09, 2007 4:37 am

LO,

i'm totally new to Joomla, and php...

I Just finished nutting out CSS/HTML, and have setup joomla on a test site. What I need to know is, is it possible to code a module or something to allow mass updating/importing of users? Idealy it would just use a TXT file that includes a persons details which they can access on a details page/update, and their website username/password. This would be stored in the mysql database.

Anyone know if something similar/the same is possible/how to? (Laymans terms please)

cheers!

User avatar
ianmac
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4785
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: Import-function for Joomla (as a component?)

Postby ianmac » Fri Mar 09, 2007 5:22 pm

Sure...  that shouldn't be too difficult.

You need some code that will read your text file, and then insert records based on that into your database.

This is easier/harder depending on the format of your text file.  Hardest part might be getting the password out of the old system, but that depends on how they are stored (i.e. if they are plain text or encoded).

Pseudo code (assuming users are stored in CSV format):
open file

while ($line = readline( filehandle )) {
$user = explode( $line, ',' );
do an md5 on the password to hash it (i.e. md5( $password )).
$query = "INSERT INTO '#__users' ...
}

Ian

SleepRequired
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Fri Mar 09, 2007 4:27 am

Re: Import-function for Joomla (as a component?)

Postby SleepRequired » Sat Mar 10, 2007 12:50 pm

OK,

the file is created by a little VB Application, writes it into a little .txt file that is comma seperated, so affectively yes .csv

Tbh, i've got no idea how i'd get the code into my joomla install, Would (It'd be a big ask I know) One of you guys if I provided you with an example .txt file, help me code something and figure out how to alter the mysql database to store the information.

ALSO: The current user information tab, doesn't carry enough fields for what the .txt file stores, can I add more fields to store info on that page, e.g. phone no/address etc etc?

regards


Return to “Joomla! 1.0 Coding”

Who is online

Users browsing this forum: No registered users and 3 guests