Forum Moderators: open

Message Too Old, No Replies

Frames - still evil?

Surely a better idea than includes?

         

Hester

4:41 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm designing a new version of my site, based around a fixed design template. Now I'm planning to use PHP 'includes' to put a page together using chunks of files. Eg: one for the header, one for the menu. That way I can easily maintain the header and menu just by changing the files included in every page.

But I'm thinking 'surely all I need is a frame?'. Imagine a page with a bar across the top and down the side. The content sits underneath this. Traditionally, it would have been a 'cool' idea to put a frame in here, so once the page is loaded, the content can change as you like, but the main page elements are already loaded for you.

However, as we know, this leads to a fixed URL. The page will always appear as say, "index.html".

But if I use includes, aren't I requesting the same page elements over and over again for each new page?

The other alternative is to define included HTML as global variables that will exist on every page. But what if someone jumped in at a different page than the start page? Maybe a quick check at the top of each page to see if the variables had been assigned or not might work.

So to sum up. What is the best way to create a template-based site? Should it be with a frame or includes? Also, do frames allow for liquid layouts?

drbrain

5:02 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you use CSS/div-based layout, you can get very a lightweight navigation bar that looks good without using frames.

For example:

#content {
margin: 50px 0 0 150px;
}

#top {
position: absolute;
top: 0;
left: 0
height: 50px;
width: 100%;
}

#sidebar {
position: absolute;
top: 50px;
left: 0;
width: 150px;
}

<div id="content">
<p>your content here
</div>
<div id="top">
<p>logo or something
</div>
<div id="sidebar">
<ul>
<li><a href="...">Home</a>
<li>...
</div>

This puts your content at the top, and moves the navigation to the bottom for the benefit of non-graphical browser users (think cell phones, too) and search engines.

For other examples, check out the csszengarden, or some of the "mozilla blogs".

Mark_A

5:11 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi Hester

I have to say that if you have a dynamic back end I do not understand why you would want to use frames really there are other issues other than the content / nav ones that caused a lot of debate about them when they were popular.

On % and frames yes you can size frames and their contents pages in % to fill a space liquidly.

re fixed url, that does not have to be the case when using frames, lets say there is the

Navigation html page
Header html page
Contents html page
and a framed page that pulls them all together.

You can create 2 pages for each contents page ..

a contents page and
a specific url frame page for that page.

Then you can make all links point to frames pages and also use the noframes text in the frames version of it.

Its will also be less likely that users will end up in orphan pages this way.

As the header and nav will be being reused there will be a flicker when they are reloaded inside the new frames page but they should locally cache so should load asap on loading a new composite page.

Anyhow to be honest I would still try to make stand alone pages for your site as its nowerdays much more what people have come to expect and generally easier to maintain and develop I feel anyhow.

irishaff

11:19 pm on Oct 31, 2003 (gmt 0)

10+ Year Member



Hi,

I use .asp includes for the header ( topbanner )on my site .

I get the benefit of being able to edit the topbanner ( graphics etc ) of the site. The file that is included also contatains the main links to other pages in the site. Each time a new page is called it does not have to reload the graphics for the top , as they are already loaded/ in cache. This benefits load times.

I dont claim to be expert , but I never had a good experience with frames in terms of SEO.

The HTML code generated on the server for the include is seamless and I dont have any problems with SEO . ( I had a nightmare with frames as the SE's indexed individual frames,, this led to users arriving on e.g the " main frame " and having no context or navigation to another page.

With ASP , you can work on SEO through the main page and usually dont have to consider the topbanner being indexed.

Hope that helps , is in the right order etc. email me at
info@parachutejump.ie if you would like links to the sites I manage so you can have a look.

David

pleeker

12:34 am on Nov 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



But if I use includes, aren't I requesting the same page elements over and over again for each new page?

Once the included file has been loaded in the user's browser, it doesn't get called again and again. It's in their cache.

An exception to that is if you have something like a Flash animation embedded in the header -- then the header actually has to reload with each page visited.

quotations

1:19 am on Nov 1, 2003 (gmt 0)

10+ Year Member




The original article which declared

"Frames are evil, the spawn of the devil"

appears to have actually been removed from CNET.com.

Only copies and mirrors are now available.

Perhaps they no longer believe it?

Hester

10:40 am on Nov 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've gone with includes using PHP. I found a neat trick whereby my menu actually changes depending on the page.

My header is always the same, then there's a footer with the disclaimer. What I found is I can even include things like the <body> tag leaving the main content to come from a set of includes.

I cannot see any speed difference from a static page before, but then I'm on broadband. Also PHP delivers a static page anyway to the browser, as it is a server-side language. (Of course using it a lot would slow down the page creation time which is something to be wary of.)

jetboy_70

3:32 pm on Nov 3, 2003 (gmt 0)

10+ Year Member



Pleeker,

Remember that PHP pages are assembled on the server as with all server-side languages. The browser requests a page which in turn requests the includes. The individual includes never make it to the browser, therefore cannot be cached (at least by the browser). This is different from client-side includes like external Javascript and CSS files, which are assembled by the client and can therefore be cached.

It is possible that the server will cache the include files, and specifying caching for oft-used files is one of the ways of speeding up the delivery of PHP pages.

Hester

4:24 pm on Nov 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My includes also contain PHP code that needs to run (only one line). However all this remains hopefully invisible to the user, who just sees the full page as before.

lorax

4:55 pm on Nov 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>> remains hopefully invisible to the user, who just sees the full page as before

Unless the PHP engine hiccups or otherwise has a problem which causes the file to be included but not processed. Then you might find your code plastered on screen - passwords and all. But I've yet to see this happen and believe the odds are highly against it ever happening.

Mark_A

5:05 pm on Nov 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Interested to read you saying that lorax.

"code plastered on screen - passwords and all"

Because if you do it right the only thing that will be there is the call to the file (outside the web path) which contains the passwords ... not the actual passwords. [As far as I know] you should not leave them in the actual file being parsed for just this reason :-)

jetboy_70

5:17 pm on Nov 3, 2003 (gmt 0)

10+ Year Member



I second Mark_A's point. In addition, any include files should have a .php extension and not something ambiguous like .inc. With this, even if they are not included correctly, they will still be parsed in isolation - possibly generating errors, but at least not displaying the source code. Alternatively (although not quite as secure) add the extension you use (such as .inc) as a PHP-parsed MIME-type in your .htaccess file.

irishaff

5:55 pm on Nov 3, 2003 (gmt 0)

10+ Year Member



just to elaborate, its graphics that ARE stored in the cache. They do not have to be downloaded with each new page just as they dont have to be re downloaded with a refresh (f5) . This assumes the same include is used on all pages ( as I think was the reason you considered using frames )

best wishes
David

davidpbrown

6:37 pm on Nov 3, 2003 (gmt 0)

10+ Year Member



Hi Hester,

I recently changed from framed site and fully recommend it to everyone, especially as PHP is so straightforward.

However the one unexpected result I saw was how much of a hit my pages took in Google. Essentially those pages that had ranked very high, then had many internal links, from the included menu. Google, I suppose reasonably, appears to consider this diminishes content quality and relevance.

Consequently I do, what I consider is, a bit of resonable cloaking and give the user exactly what they want.. ie. externally referred users, ones that maybe have searched for a specific page, get 100% pure content + one link to the home page, internally referred users get content + menu. This then achieves *exactly* what the frames were delivering, which is why I don't expect Google will object.

If you do this though, it appears ~10% users have firewalls etc that strip referral info from requests and so could be mistaken as external requests.. but being liberal I've little sympathy with that mindset so leave them to suffer.

While I'm thinking of it you might be interested in [xml.com ]
and the code to do that I use is suggested at [webmasterworld.com ]

dpb

lorax

6:58 pm on Nov 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>> Because if you do it right

Correct, but there are ways to do it wrong and it is possible for the PHP engine to include the file but not process it. Failing on the MIME type as jetboy_70 points out comes to mind. The point of my comment being that PHP includes are not devoid of potential failures. This is not to say they are unsafe. If I felt so, I would not use them as extensively as I do!