I have a site done with frames, and I like the concept to separate information in different files. I included code to force some pages to download in the right frameset. But I hear that this is an old technology that has a lot of problems. Is this completely true? What are the best solutions? I appreciate your help.
Can frames be a good choice? What then?
If you are just using frames for navigation and sidebar purposes, then I would recommend that you use something similar to do a similar job.
You can use
. That would put the contents of something.html inside your main html document (let's say index.php), so that could be used to seperate information in different files, like you said.
The main disadvantage for frames is that the information displayed inside the frame is not accessable to agents such as the bots used by search engines to index your site. Also, frames don't display (well) in other agents such as portable ones, found in PDA's, cell phones, and other portable devices such as the PSP, or text-based ones (though I've never tested it) such as the popular Lynx. I would imagine that frames don't render well in other browsers, such as braille-based ones, or voice synthesizers, such as JAWS.
If you like frames for the ease of use, and the ability to create pages without having to type <link rel="text/css"> and <div id="container"> and all that when creating a new page, consider doing a "dynamic content" system with PHP, such as in this topic.
You can use
| Code: |
| <?php include(something.html); ?> |
The main disadvantage for frames is that the information displayed inside the frame is not accessable to agents such as the bots used by search engines to index your site. Also, frames don't display (well) in other agents such as portable ones, found in PDA's, cell phones, and other portable devices such as the PSP, or text-based ones (though I've never tested it) such as the popular Lynx. I would imagine that frames don't render well in other browsers, such as braille-based ones, or voice synthesizers, such as JAWS.
If you like frames for the ease of use, and the ability to create pages without having to type <link rel="text/css"> and <div id="container"> and all that when creating a new page, consider doing a "dynamic content" system with PHP, such as in this topic.
I didn't know that php feature. That's great. Thanks riv for that hint. My PHP knowledge is still almost zero but I plan to learn that as long as I've got a site here at Frihost. I know many features of C and Pascal, so I think it won't be hard to build also with PHP.
Riv, you seem quite ahead at this PHP thing, so I ask you if by using php with the include thing the problems with frames (searching,showing,printing,disability people oriented) are avoided?
Opinions are appreciated!
Riv, you seem quite ahead at this PHP thing, so I ask you if by using php with the include thing the problems with frames (searching,showing,printing,disability people oriented) are avoided?
Opinions are appreciated!
I agree with riv, i'm also using the same php funciton for almost all of my websites, and I'm very very far from professional in php
Someone once showed me how to use this php feature instead of frames and i've been using it all the time sice then. It's real easy, you just create the whole site in html like you usually do, then insert this code before the <body> tag:
<?php
$p=$_GET["p"];
if ($p == null){$p = 'home.php';}
else {$p = "$p.php";}
if (!file_exists($p)) {$p = 'home.php';}
?>
insert this where you want all of your pages to open:
<?php
if (file_exists($p)) {include($p); }
?>
give your file .php extension.
And now all you have to do is create separate pages (like contact.php, about.php) with no tags, and they will automatically open in your text field when clicked on. It kind of works like frames, but much better and less fuss.
Also, for the links use this: index.php?p=filename (with no extension)
Hope this helps
Someone once showed me how to use this php feature instead of frames and i've been using it all the time sice then. It's real easy, you just create the whole site in html like you usually do, then insert this code before the <body> tag:
<?php
$p=$_GET["p"];
if ($p == null){$p = 'home.php';}
else {$p = "$p.php";}
if (!file_exists($p)) {$p = 'home.php';}
?>
insert this where you want all of your pages to open:
<?php
if (file_exists($p)) {include($p); }
?>
give your file .php extension.
And now all you have to do is create separate pages (like contact.php, about.php) with no tags, and they will automatically open in your text field when clicked on. It kind of works like frames, but much better and less fuss.
Also, for the links use this: index.php?p=filename (with no extension)
Hope this helps
| romaop wrote: |
| I didn't know that php feature. That's great. Thanks riv for that hint. My PHP knowledge is still almost zero but I plan to learn that as long as I've got a site here at Frihost. I know many features of C and Pascal, so I think it won't be hard to build also with PHP.
Riv, you seem quite ahead at this PHP thing, so I ask you if by using php with the include thing the problems with frames (searching,showing,printing,disability people oriented) are avoided? Opinions are appreciated! |
Searching, showing, printing, accessibility, all those problems associated with frames are totally avoided with include in PHP - since the browser (and search engine etc.) will see the page as one single page - PHP just puts the parts of your pages together into one page which is then sent to the browser. So it's as if you'd copy/pasted the pieces into each file yourself.
Also, might be worth noting that this is not exclusive to PHP. ASP and ASP.NET or any other server side scripting language allows similar approaches - and even hosts with no scripting support often have the possibility of SSI (Server Side Includes), which is less powerful, obviously, but still allows you to put the header, footer, navigation etc. into separate files, and include them into your various pages before they're sent to the browser. In that case, if you had a file like "footer.html", you could do:
| Code: |
| <!--#include virtual="/footer.html" --> |
... and the server would add the contents of footer.html at that point.
The way I usually do it in PHP (because I want maximum flexibility for each page (one page may be a blog, one a forum, another a test page for some web technology experiment...), but I still want it to be easy to modify layout etc. globally) is like (simplified quite a bit):
| Code: |
| <?php
$page_title = 'Experiences with the Monster'; include($_SERVER['DOCUMENT_ROOT'] . '/header.php'); ?> <p>Blah blah blah blah</p> <!-- etc. - all content goes here --> <?php include($_SERVER['DOCUMENT_ROOT'] . '/footer.php'); ?> |
... then in header.php, in the <title> tag etc. I output the value of $page_title (so the title will be different from page to page). Same thing with an <h2> tag at the end of the footer (so the actual page content will start with a headline - same text as the page title. Etc. I do something similar for pagespecific javascripts, style sheets etc. (maintain an array of scripts which are then output as <script src="whatever" type="text/javascript"> tags through a loop in the header).
What it comes down to is, for each different page of the site, I only set up a few variables for the page specific stuff - title, scripts etc., include the header and footer, and then write the actual content.
Related topics
