|
Pages: [1]
|
 |
|
Author
|
Topic: Converting from HTML to PHP (Read 1389 times)
|
Berlin-Bob
Global Moderator
RootsChat Marquessate
      
Offline
Posts: 4926

by My Daughter. Chatting to find her Roots !
|
This topic is in response to a query from Kateblogs.
I am hoping to be able to use a server side include to 'call up' the unchanging content on each page, for example the navigation links, page header and so on. I have done this on other web pages and it is a lot easier to change the content of one file than to alter each and every page. If it isn't possible that's ok, I just thought it would be useful to know if I could. Kate
and
Thank you to everyone for your help. I tried Zeb's suggestion, but it doesn't look as though ssi [mod: server side includes] is enabled.
Could anybody explain how I could do a similar thing with php?
Here goes 
First stage:
- create a "working" copy of your website, on your hard disk
- rename all .htm or .html files in this directory to .php
- using an editor, in each (and every) PHP page, change the .htm or .html in all the internal links to .php
At this stage you should be able to upload to your website and it will work, just as before. This is useful if you want to do the next stage bit-by-bit 
The next stage is more difficult.
Using one of the files as a 'template', For each "fixed" item, you need to copy the HTML code from your program into a seperate file.
On my website, I have the same basic structure for all pages (see below) So I have 4 files: 1. nav_top.inc.php Top navigation bar 2. nav_end.inc.php Bottom navigation bar 3. menu.inc.php Menu 5. (actually two files) link_text.inc.php and contact_me_text.inc.php After thinking about it a while, I decided to simply make one file of them, called footer.inc.php
The .inc in the file name is not really necessary, but I use it to remind me that this is not a complete program, but a file that I will include
Now comes the boring bit . . .
In every file, you have to delete the code for the * top navigation bar and replace it with <?php include( "./nav_top.inc.php" ); ?> * bottom navigation bar and replace it with <?php include( "./nav_end.inc.php" ); ?> * menu and replace it with <?php include( "./menu.inc.php" ); ?>
Do the same for any other bits of "boiler plate that appear on every page, and you're done !
This is a bit "concise", so ask if you have problems, there are several people who can help out.
Bob
ps. you can choose your own names for any of these files (of course ), this was just for the sake of example.
|
Searching for Coleman, Moore, Kallnung in London; Margulies, Remenyi in E. Europe; Ancestors of Hessie Stevenson-Coleman-Baxter (Ireland, 1861) and, of course, any other ancestors for my web-site http://boco.rootschat.net All Census Data included in this post is Crown Copyright (see: www.nationalarchives.gov.uk)
|
|
|
Berlin-Bob
Global Moderator
RootsChat Marquessate
      
Offline
Posts: 4926

by My Daughter. Chatting to find her Roots !
|
I am also adding a header.inc.php to each page This is basically the meta-tags:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title><?=$page_title?></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="author" content="Bob Coleman"> <meta name="copyright" content="Bob Coleman"> <meta name="date" content="<?=$metatag_date?>"> <meta name="description" content="Family Chronicles Hanns Margulie / Hans Margulies, the Margulies-Remenyi, Benson-Kennedy, Stevenson-Ferrie and Coleman-Moore-Breeze Families (and others)"> <meta name="keywords" lang="en" content="Family History,Genealogy"> <meta name="keywords" content="Benson,Baxter,Breeze,Champion,Coleman,Ferrie,Hoey,Gardner"> <meta name="keywords" content="Hopes,Kennedy,Lewis,Margulies,Malacek,Margoliot,Moore,Morrison"> <meta name="keywords" content="Morser,Pearse,Remenyi,Richards,Riding,Stevenson,Vachre,Varney,Vatcher"> <meta name="robots" content="index,follow">
<meta http-equiv="Content-Style-Type" content="text/css"> <link rel="stylesheet" type="text/css" href="./mm-scr.css" media="screen"> <link rel="stylesheet" type="text/css" href="./mm-prn.css" media="print"> <link rel="stylesheet" type="text/css" href="./mm-trees.css" media="all"> </head>
but with a difference: note this line <title><?=$page_title?></title> and this one <meta name="date" content="<?=$metatag_date?>">
Each of my web pages now starts like this:
<?php
$page_title = "A Margulies Miscellania"; $metatag_date = "2006-10-05"; $page_update = "05.10.2006";
include( "./header.inc.php" ); ?> <body> : : By making the title and date variables, I don't need to change the header.inc.php file. Instead, I just put in the appropriate title for each page, and change the value of $metatag_date and $page_update whenever I update an individual page.
Bob
ps don't forget the end tags </body> and </html> at the bottom of the page 
|
|
|
|
|
Logged
|
Searching for Coleman, Moore, Kallnung in London; Margulies, Remenyi in E. Europe; Ancestors of Hessie Stevenson-Coleman-Baxter (Ireland, 1861) and, of course, any other ancestors for my web-site http://boco.rootschat.net All Census Data included in this post is Crown Copyright (see: www.nationalarchives.gov.uk)
|
|
|
|
|
Berlin-Bob
Global Moderator
RootsChat Marquessate
      
Offline
Posts: 4926

by My Daughter. Chatting to find her Roots !
|
Keep us posted !!
I have about 100 files to change, and not much time at the moment.
I also have the problem, that the "family" files are in the root directory, and the biographies in a seperate directory. So I will need two each of the navigation and menu files, one for the root and one for the biography directory. Most of the biography files haven't got the new structure yet, so I will do that at the same time.
I'll post any problems I find, here.
. . . in between working, and doing this and that 
Bob.
|
|
|
|
|
Logged
|
Searching for Coleman, Moore, Kallnung in London; Margulies, Remenyi in E. Europe; Ancestors of Hessie Stevenson-Coleman-Baxter (Ireland, 1861) and, of course, any other ancestors for my web-site http://boco.rootschat.net All Census Data included in this post is Crown Copyright (see: www.nationalarchives.gov.uk)
|
|
|
|
|
Zeb
RootsChat Senior
   
Offline
Posts: 431

|
Nice one BB, I'd thought about writing a tutorial similar to this a while back but decided against it for various reasons.
The whole reason I started learning PHP was so I can use includes. For example, having loads of files with the same menu and wanting to change one small feature meant having to edit all those HTML files. With includes all you have to do is edit that one include and the entire site changes. I then took it to the next level and started learning PHP properly.
BB, if you want I'll write a small tutorial on how to make a picture viewing script, handy for when you've got a lot of photographs on the website and don't want one file for each picture. This will make the site a bit smaller.
|
|
|
|
|
Logged
|
Derby: WOODCOCK (Donnington) Devon: HARRIS (Plymouth) Lancashire: DERRICK Lincolnshire: CROPPER, WOODCOCK (Boston) London: BARKER, DUGGIN, HARRIS, HINTON, HULBERT, WHITE Wales: HARRIS, PRITCHARD (Pembrokeshire) Warwickshire: DERRICK, WOODCOCK Desperate for my Woodcocks from Birmingham!
|
|
|
Berlin-Bob
Global Moderator
RootsChat Marquessate
      
Offline
Posts: 4926

by My Daughter. Chatting to find her Roots !
|
I've now finished converting my website to PHP (about 3 weeks of spare time !!)
It looks just the same as before, and the contents are the same, but now all pages have the same structure
the sections marked 1, 3 and 4 are each one PHP file which is written once and then included in every page.
The menus (2) consist of 6 files - one for the index-pages, and one each for the five family groups.
The include files are roughly 4 KB of code, so on a website of 100 pages, I've saved roughly 0.4 MB space, which I can now use for more contents 
The biggest saving, is that if I add a page, then instead of adding it to the menu on maybe 20 pages, I just need to add it once to the menu file for that particular family group, and it will automatically be included in all the relevant pages.
One job still to do: I need to write redirect files for all those who are using older search engine links.
Bob
|

website.jpg (44.75 KB, 700x352 - viewed 260 times.)
|
|
« Last Edit: Tuesday 19 December 06 06:48 GMT (UK) by Berlin-Bob »
|
Logged
|
Searching for Coleman, Moore, Kallnung in London; Margulies, Remenyi in E. Europe; Ancestors of Hessie Stevenson-Coleman-Baxter (Ireland, 1861) and, of course, any other ancestors for my web-site http://boco.rootschat.net All Census Data included in this post is Crown Copyright (see: www.nationalarchives.gov.uk)
|
|
|
|
|
|
|
Berlin-Bob
Global Moderator
RootsChat Marquessate
      
Offline
Posts: 4926

by My Daughter. Chatting to find her Roots !
|
Hi Mike,
for the most part, the tutorial deals with uploading to your site (FTP) and using family history software to create a website.
It is not meant to be an HTML tutorial. Neither do I intend writing a PHP tutorial.
If you, or anybody else, is writing a website in HTML, then you will need to think about PHP at the design stage:
- which "bits" will I keep repeating on every, or almost every page
Then you can plan to include these "bits" as PHP files.
The results from any webpage "creation" program can also be edited in this manner (with "donkey work"), but there is then the problem, that if you update your pages using the webpage program, then the hand-crafted PHP changes may have to be repeated each time.
I have a feeling that PHP may only be an option for those who
- a) write their site from scratch, in HTML or
- b) use a program to create websites, just to get the basic site up and running, but then always edit individual pages, using an editor.
Bob
|
|
|
|
|
Logged
|
Searching for Coleman, Moore, Kallnung in London; Margulies, Remenyi in E. Europe; Ancestors of Hessie Stevenson-Coleman-Baxter (Ireland, 1861) and, of course, any other ancestors for my web-site http://boco.rootschat.net All Census Data included in this post is Crown Copyright (see: www.nationalarchives.gov.uk)
|
|
|
tucson mike
RootsChat Extra
 
Offline
Posts: 38

|
Bob,
Thanks for your reply. It helps clarify things.
Even just looking at the tools available from www.coffeecup.com, for example, they have both what they call an HTML Editor, which also knows about PHP, and a VisualSite Designer. The Designer is easier to use for creating a site whose pages all have the same look & feel. But I've already encountered the problem of having to make the same change on multiple pages in the Designer.
So I may try using the Designer to get my basic site up & running, but edit individual pages after that, as you suggest. I'll have to think about it.
Mike
|
|
|
|
|
Logged
|
Ireland: Rosemount/Westmeath & Offaly/Fearboy: Stones & Maguire, 1850 - 1900. Waterford/Waterford: Anna Cleary, born about 1862, emigrated to US before 1880. Henry Carroll, emigrated to US before 1880. England: Lancashire/Liverpool: Fogarty & Patterson, 1906.
|
|
|
Berlin-Bob
Global Moderator
RootsChat Marquessate
      
Offline
Posts: 4926

by My Daughter. Chatting to find her Roots !
|
Hi Mike,
I'll have to think about it. At the risk of sounding trite, I'll just say: Do that !!
I have now re-designed my website three times, on a learning-as-I go-along basis and I can recomend thinking about it, a lot, before actually starting doing anything.
the PHP conversion is the latest re-design, and I didn't know PHP when I first started, so I can't really say "I should have done it then".
At some time, you will stop "thinking" and just start doing, just so that "something is happening !!!", so the more thought at the beginning, the better.
Whatever you do, you will still change it at some time (the design, I mean - changing the contents is a Given !) so keep that in mind and accept it will never be perfect.
Sometimes I need to see my first thoughts "in action" to be able to decide if that is the way I want it. My website is also my "toy" so (for me) it's part of the fun.
Good luck with whatever you do, and keep us posted  Bob
|
|
|
|
|
Logged
|
Searching for Coleman, Moore, Kallnung in London; Margulies, Remenyi in E. Europe; Ancestors of Hessie Stevenson-Coleman-Baxter (Ireland, 1861) and, of course, any other ancestors for my web-site http://boco.rootschat.net All Census Data included in this post is Crown Copyright (see: www.nationalarchives.gov.uk)
|
|
|
|
Pages: [1]
|
|
|
|
|