Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
02-19-2008, 08:37 AM #1
- Join Date
- Jan 2008
- Thanked 0 Times in 0 Posts
get content of each .HTML files & put it in database
I have a old site that is 100% plain html files. I'm looking to migrate the site to work with a php-built CMS. The problem is that i have thousands of articles in html format, and I don't want to add them all one-by-one through the admin section of my CMS. So the only solution for me is to find a code that would take the html codes inside each of my static html files, and create an entry in my database with the content found.
My site's structure is currently like this:
www.mysite.com/books/Name Of The Book.html
I have chosen JOOMLA for my CMS. Joomla stores its articles in a table called "jos_content"
the structure of "jos_content" for the imporant article infos is:
"id" = ID of the article, so we have to increase this by one for each new article
"title" = Title of the article. In my case i'd put here the filename of the .HTML since it is the title of my articles
"introtext" = text of the article. It should be the content inside of my HTML files
So basically i'd need a code that would look for these informations and create a new entry for each of the .HTML files found in my /books/ server. For the rest I can do it myself, but if someone can hook me up with a code that would do what I explained above it would greatly help me to have somewhere to start since i'm still a newbie with php!
02-19-2008, 11:55 AM #2
- Join Date
- Mar 2003
- Thanked 30 Times in 28 Posts
Do you want the entire contents (everything in the <head> section, any embedded CSS, the <body> tag and everything inside) of the .html file in the "introtext" field? Or do you want to put a certain part of each html?
If you want the whole thing inside..use file_get_contents(). and then just run a query.
If you want certain sections in certain spots you'll need to parse the file to pull out what you want. But we'd need to know what the file looks like and what you want to go where in order to help you.
Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.