Forum Moderators: open
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?
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".
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.
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
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.
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.)
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.
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.
"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 :-)
best wishes
David
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
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!