+ Reply to Thread
Results 1 to 8 of 8

Thread: Converting static HTML website to dynamic PHP website

  1. #1
    bhupendra2895's Avatar
    bhupendra2895 is offline x10 Elder bhupendra2895 is an unknown quantity at this point
    Join Date
    Jun 2010
    Location
    India
    Posts
    554

    Converting static HTML website to dynamic PHP website

    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?

  2. #2
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Converting static HTML website to dynamic PHP website

    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.

  3. #3
    bhupendra2895's Avatar
    bhupendra2895 is offline x10 Elder bhupendra2895 is an unknown quantity at this point
    Join Date
    Jun 2010
    Location
    India
    Posts
    554

    Re: Converting static HTML website to dynamic PHP website

    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.
    Liked this? Click on the icon on the bottom of post to make me .

  4. #4
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Converting static HTML website to dynamic PHP website

    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.

  5. #5
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,267

    Re: Converting static HTML website to dynamic PHP website

    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.
    Nothing is always absolutely so.

  6. #6
    misson is online now Community Advocate misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,391

    Re: Converting static HTML website to dynamic PHP website

    Regarding URLs and links, if you use extensionless URLs (using content negotiation, mod_rewrite or even PHP), you'll never have to update links. Once you have extensionless URLs, the next step is to realize you can completely divorce external from internal URLs (using mod_rewrite). This lets you choose URLs wisely. In particular, URLs should name resources; they're nouns, not verbs.

    As Tim Berners-Lee wrote, cool URIs don't change (later updated for the semantic web).
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  7. #7
    bhupendra2895's Avatar
    bhupendra2895 is offline x10 Elder bhupendra2895 is an unknown quantity at this point
    Join Date
    Jun 2010
    Location
    India
    Posts
    554

    Re: Converting static HTML website to dynamic PHP website

    Quote Originally Posted by lemon-tree View Post
    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,

    Quote Originally Posted by descalzo View Post
    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?

    Quote Originally Posted by descalzo View Post
    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?

    Quote Originally Posted by misson View Post
    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.
    Liked this? Click on the icon on the bottom of post to make me .

  8. #8
    misson is online now Community Advocate misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,391

    Re: Converting static HTML website to dynamic PHP website

    Quote Originally Posted by bhupendra2895 View Post
    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 by misson; 08-01-2010 at 04:03 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Replies: 0
    Last Post: 04-12-2010, 03:09 AM
  2. how to add a forum to html website?
    By gomcoite in forum Graphics & Webdesign
    Replies: 12
    Last Post: 04-30-2008, 03:54 PM
  3. Html code comes up instead of the website
    By AnjUltra in forum Free Hosting
    Replies: 5
    Last Post: 12-14-2007, 08:32 PM
  4. Dynamic website not working
    By yahia in forum Free Hosting
    Replies: 19
    Last Post: 09-28-2007, 01:59 PM
  5. showing html on website
    By swirly in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 12-04-2005, 09:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers