Converting static HTML website to dynamic PHP website

bhupendra2895

New Member
Messages
554
Reaction score
20
Points
0
Hi,
I have a static html site with 1339 html pages.I want these pages to be converted into php pages.These static html pages have some common header and footer elements.

I know that I can change extension of all files, but I want to place dynamic banners in header and footer, as well as breadcumbs (a navigation system:- for eg home->books->php)

How I can do that with less labour and optimal output? :smile:
 

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
Unless you can find an app that does batch replace, you'll have to do it by hand. Make sure you don't just replace the headers, but instead place the new header code in a globally accessible file and use the PHP include() function; this method means you can just change the one file and all of the headers will update simultaneously.
 

bhupendra2895

New Member
Messages
554
Reaction score
20
Points
0
I found a program called flash renamer in windows, using it I changed extension of all html files to php.

I have replaced all the tags below and above body tag by null(I mean they are eliminated) and included two php files on top and bottom of page by replacing body opening tag and body closing tag in all pages.

I just want now a good navigational menu in bottom.For that I am using $_SERVER['REQUEST_URI'] global.Is it secure or I should use $_SERVER[PHP_SELF].

Now for doing this I need to split the array using preg_split() and as well as I need to compare a multidimensonal array containing predefined directories and subdirectories with the array created by preg_split() of $_SERVER['REQUEST_URI'].I did that using array_search().But I think its just waste of server resources, because it may slow down execution of php pages.

Also as I mentioned, I have replaced all the tags above body, it means unique title in all pages is lost, so I need to do this in my header.php script included in top.

My site is a mobile content site and I assume I might have to go through all the pages for setting page specific variables.I have back up of my old site.So if you have any better idea please suggest.
 

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
When you get to the point that you have so many similar pages then you know it is about time you moved to using a single php template file into which the content is loaded from a database. This means you only ever have to edit one page and the content is very easy to create and maintain as it is all built within a MySQL database; this is how all CMSs do it as it is the most efficient and the most expandable. I think this is something you should certainly consider.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Depending on how regular the pages were, I would run them through a Perl script to do the transformation.

Did you edit all the internal links so they point to the .php version instead of the .html version?

From your description of the site as 'static', I would not go the MySQL route. Just one more thing that can go wrong. Look at the Free Hosting forum when the MySQL starts acting up. Sites are unusable.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48

bhupendra2895

New Member
Messages
554
Reaction score
20
Points
0
When you get to the point that you have so many similar pages then you know it is about time you moved to using a single php template file into which the content is loaded from a database. This means you only ever have to edit one page and the content is very easy to create and maintain as it is all built within a MySQL database; this is how all CMSs do it as it is the most efficient and the most expandable. I think this is something you should certainly consider.

Thanks for suggestion,
Yes I want to use Mysql database, but currently I don't want to do it because,

1)As Descalzo said,

From your description of the site as 'static', I would not go the MySQL route. Just one more thing that can go wrong. Look at the Free Hosting forum when the MySQL starts acting up. Sites are unusable.

It will make my site dependent on mysql server, so if it goes down then my site goes with it, it also mean I neede to write additional conditional statement to do the damage control.

2)Since all information is stored in over 1000 files, how can I store all of them in database and how I can retrieve them?

Depending on how regular the pages were, I would run them through a Perl script to do the transformation.

Did you edit all the internal links so they point to the .php version instead of the .html version?
Thanks, Yes I have changed all internal links to php, it was easy just find and replace function of my editor did that.I guess you are suggesting me to pass all requests by client browsers through a single script?

As Tim Berners-Lee wrote, cool URIs don't change (later updated for the semantic web).

Thanks, I am going to implement my site in zend framework, Because in zend framework (MVC) every request by client goes through only index.php on webroot and it has inbuilt support for cool URLs and CMS can be built easily over it as well.

The main problem is File created from July 2009 to Till now, how to integrate them.Because I don't have too much time to invest and I can't write too much views, controller and actions.My quick and dirty plan is that let's provide support for old content in this way (without any cms), and new content should be processed through Zend framework.I should do it in this dirty way or I shuld invest time.My site is a download site.So content goes old with time.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
My quick and dirty plan is that let's provide support for old content in this way (without any cms), and new content should be processed through Zend framework.I should do it in this dirty way or I shuld invest time.
That's a good plan. Implement new stuff with new techniques, slowly convert old stuff, and redirect old URLs to new ones to prevent link rot.
 
Last edited:
Top