PHP Includes and iframes
I would like to change the content of an area on my webpage when a user clicks on the menu.
What is the most appropriate method to use PHP includes or frames??
What are the pros and cons......
Direction required for a newbie
frames/iframes are really losing usefulness nowadays. Pretty much any realistic task you want to accomplish with them can be done efficiently without them - besides, some of the less mainstream browsers (such as Lynx/Links, text based browsers - VERY GOOD text based browsers ) don't support frames, styles, or any of that extra stuff - they are designed to display content only, focusing on accessability over attractiveness. Frames cause extra problems, because if your browser doesn't support frames, you can't view the site. Period. Not the case with CSS or styles - if the browser doesn't support it, the content still shows up, minus pretty formatting.
Frames tend to disrupt the flow of content, which makes it hard for people with disabilities to use your site (IIRC it affects text readers for the blind, and keyboard navigation with frames is a hassle too).
PHP Includes are something completely different - it allows you to just include a separate file into the normal flow of the site, and is controlled by the server rather than the client. For instance, when you request a site with PHP (or SSI) includes in the code, you don't actually know it - all you see is the final product in the source code, not the PHP or SSI stuff.
- search engine friendly
- doesn't bring up bookmarking issues
- doesn't require whole other documents
- Easier for you
- Tiny bit faster
PHP all the way IMO
Thank goodness I've made the right choice in choosing to use php includes which I found actually quite easy to use (I must have done something wrong :-) )
I have another question regarding PHP includes - the tutorial I used suggested creating a new index page for each new page I wanted to pull thorough the site e.g.
so if I want to add booking_forms I need to add booking_forms.php and booking forms.htm
is there anyway of cutting out the .php file??
link to the site I'm working on http://www.**********.co.uk/pioneer/index.php
Please keep it simple, up until an hour ago I hadnt touched php.
Cheers to all.
You could have one PHP file for each page, in which case the php file would consist of what's different and would include what's the same.
Or you could have one PHP file for every page wich would consist of what's the same, and include what's different.
Thanks Tree...I think.
I thought there might be a clear bit of php which would negate the need to reproduce the php page for every new html page.
click button 1 goto html content1
click buttom 2 goto html content2
but all in the same php page
Am I making sense? I've seem this type of thing on other sites and wondered if the php searched for the appropriate html page??
Last edited by SimonBahr; 07-09-2005 at 08:06 AM.
O.k. lets say your going to have one php document and you're going to call it index.php, then all of your content can be in include files in a folder called content.
index.php would be stuff like doctypes and head infomation, with a tiny little script to include a file based on the url (e.g. index.php?page=foo).
You'd start with the plain HTML that you want all your documents to start with.
This would be the script. It takes from the URL, makes a file path out of it and includes that file.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
<title>The Pages of Doom</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
<meta name="keywords" content="Pages, Doom">
<meta name="description" content="Many pages, all with doom included.">
<link href="stylesofdoom.css" rel="stylesheet" type="text/css">
If it were given index.php?page=foo then it would include content/foo.inc.
In the event of not being given a page, it'll just go for a default file.
Then you'd finish up, often with a lot of closing tags.
You can then link between these dynamic documents like so:
Last edited by the tree; 07-09-2005 at 10:13 AM.
Thank you. I think what you're saying is that my contents includes in my index.php should be replaced with this new script which will fetch the appropriate page from the content folder based on the url.
I noticed that your foo page did not have an .htm/.html extension and has .inc. What is the relevance?
It doesn't really matter what extension it is, however a number of web developers use .inc to specify a file as an include - makes organization a little easier.
Thanks to all.
This exactly what I was looking for.....tried, tested and now up and running.
Many thanks Si
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)