Welcome, Guest. Please login or register for free.
Did you miss your activation email?
Monday 07 July 08 01:56 BST (UK)
Welcome Home Help Shop Search Calendar Login Register
Search Images 

Online
 
  First Name(s)

Last Name

 
News: Ad: New! FULL 1841 Census: England - Isle of Man - Wales  - Channel Islands Now online. No missing counties.

+  RootsChat.Com
|-+  General
| |-+  The Common Room
| | |-+  Free RootsChat Webspace (Moderator: trystan)
| | | |-+  Converting from HTML to PHP
« previous next »
Pages: [1] Print
Author Topic: Converting from HTML to PHP  (Read 1390 times)
Berlin-Bob
Global Moderator
RootsChat Marquessate
*******
Offline Offline

Posts: 4926


by My Daughter. Chatting to find her Roots !


WWW
Converting from HTML to PHP
« on: Monday 09 October 06 18:08 BST (UK) »

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  Grin Grin Grin

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 Smiley

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  Grin ), this was just for the sake of example.


* beispiel.jpg (63.92 KB, 774x410 - viewed 299 times.)
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 Offline

Posts: 4926


by My Daughter. Chatting to find her Roots !


WWW
Re: Converting from HTML to PHP
« Reply #1 on: Monday 09 October 06 18:23 BST (UK) »

I am also adding a header.inc.php to each page
This is basically the meta-tags:
Code:
<!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:
Code:
<?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  Grin Grin

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)
kateblogs
RootsChat Extra
**
Offline Offline

Posts: 81


Youth is wasted on the young


WWW
Re: Converting from HTML to PHP
« Reply #2 on: Monday 09 October 06 18:55 BST (UK) »

Thank you Bob! You have explained in terms I can understand. Fortunately, my site is very new, so it shouldn't take me too long to swap over. My sympathies to anyone who decides to use Bob's method and who needs to adapt hundreds of pages  Cry It is worth doing though - in the future you only need to change one file to update sections of your site!

Thanks again Bob - you have made this budding family history researcher a very happy bunny  Cheesy

Kate
Logged

BARNES - Nottinghamshire
GILBY - Essex, Warwickshire and Cambridgeshire
HANFORD/HANDFORD - Dorset, Nottingham and Edinburgh
HOLMES - Nottinghamshire
LINTHWAITE - Nottinghamshire
MASON - Cambridgeshire
MCSHANE - Ireland and Liverpool
MORRISON - East Riding (Hull) and Edinburgh
OWENS - Yorkshire (West Riding) and Ireland
PUGH - Yorkshire, Derbyshire, Cheshire
RYLANDS - Liverpool and Ireland
SANSAM - Nottinghamshire
TODER - Nottinghamshire
WAYNE - Birmingham and Nottingham
WILSON - Nottingham
Berlin-Bob
Global Moderator
RootsChat Marquessate
*******
Offline Offline

Posts: 4926


by My Daughter. Chatting to find her Roots !


WWW
Re: Converting from HTML to PHP
« Reply #3 on: Monday 09 October 06 19:02 BST (UK) »

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   Grin Grin

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 Offline

Posts: 4926


by My Daughter. Chatting to find her Roots !


WWW
Re: Converting from HTML to PHP
« Reply #4 on: Monday 09 October 06 19:10 BST (UK) »

Ooops, forgot to mention this:

for Kate, and anybody else thinking of doing this:

The answer is YES, RootsChat free webspace does support PHP  Grin Grin

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 Offline

Posts: 431



WWW
Re: Converting from HTML to PHP
« Reply #5 on: Tuesday 10 October 06 15:03 BST (UK) »

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 Offline

Posts: 4926


by My Daughter. Chatting to find her Roots !


WWW
Re: Converting from HTML to PHP
« Reply #6 on: Saturday 28 October 06 17:14 BST (UK) »

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  Grin

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 Offline

Posts: 4926


by My Daughter. Chatting to find her Roots !


WWW
Re: Converting from HTML to PHP
« Reply #7 on: Tuesday 19 December 06 06:56 GMT (UK) »

As an example of how easy it is to change things
(after doing all the donkey work of changing to PHP  Grin ):

I recently changed the "bottom line" on my site

I edited 2 files (see (3) and (4), above) and the results, as below, appeared on over 100 pages.

Bob


* website02.jpg (60.8 KB, 688x361 - viewed 208 times.)
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 Offline

Posts: 38



Re: Converting from HTML to PHP
« Reply #8 on: Friday 29 December 06 20:37 GMT (UK) »

Bob,

Well, there seems to be an obvious question lurking hereabouts, so I'll ask it. Your tutorial "Step-by-step guide to building your website" does not mention using PHP right from the start. And your explanation here of how to convert from HTML to PHP calls some of the conversion "donkey work."

Do you have any recommendations for someone (like me) who's starting fresh, as to how to bypass the donkey work by using PHP to begin with?

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 Offline

Posts: 4926


by My Daughter. Chatting to find her Roots !


WWW
Re: Converting from HTML to PHP
« Reply #9 on: Friday 29 December 06 20:54 GMT (UK) »

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 Offline

Posts: 38



Re: Converting from HTML to PHP
« Reply #10 on: Friday 29 December 06 21:53 GMT (UK) »

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 Offline

Posts: 4926


by My Daughter. Chatting to find her Roots !


WWW
Re: Converting from HTML to PHP
« Reply #11 on: Friday 29 December 06 22:11 GMT (UK) »

Hi Mike,

Quote
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  Smiley
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] Print 
« previous next »


[Copyright] [Free RootsChat Webspace] [Your Surname Interests] [Shrink Link] [About Us] [Terms of Use]
All Census Lookups are Crown Copyright, National Archives for academic and non-commercial research purposes only
RootsChat.com cannot be held responsible directly or indirectly for the messages or content posted by others. Inline images in messages are the copyright of the respective linked sites.
RootsChat.com, Europa House, Bury, Lancashire, BL9 5BT
0.183:22