Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to store common web content separately

Status
Not open for further replies.

redss

Programmer
Oct 20, 2002
195
I have several web pages that all share the same graphical menu on top and the left, and I want to store that common html in its own file and include a reference to it in my content pages.

what is the easiest way to do that and be able to preview the completed pages in my browser? (without using php/asp/cfm, etc)

I am under the understanding that server side includes require the use of a web server to populate with the contents of the included file (making local preview difficult when not connected to the server), and besides, most websites I see have a .html extension not .shtml extension, so what technique are they using so that all the pages don't have to be individually updated when the top menu needs to be changed?
 
If you have acess to PHP, you could use an include(), or a require(), and load the text... Else, you'd be stuck with copy and paste... Unless you want to use Perl or C++ (which would be a bit more involved).
 
The easiest way to do it is using a frameset. Alternatively you can simulate server-type includes by putting your includes in a JavaScript file which each screen references.

Clive
 
thanks for your reply - I wholeheartedly agree, a frameset is the way to go. However I need to implement some DHTML that won't work across the frames, so mainly at this point my question is: how are these other sites doing it since their file extension is .html rather than .shtml ????

I have never seen an example of where javascript can easily import html into a file; do you have a simple code example of javascript doing that? I worked on a project where the nested document.write's got to be a nightmare!
 
Well any html that you want to import via a JavaScript file would simly need to be surrounded by a document.write or a document.writeln.

Example:
document.writeln('MY HTML HERE')
document.writeln('More HTML HERE')

etc.

Clive
 
ASP can do it. It just calls another file and runs it right where you want it to. Does your host support ASP?

-Volkoff007
 
how are these other sites doing it since their file extension is .html rather than .shtml ????

The extension has nothing to do with it, it depends on the server setup.

You could very easily setup a server to process .pl as php, .php as Perl, .cfm as asp etc etc.

Hope this helps

Wullie


The pessimist complains about the wind. The optimist expects it to change.
The leader adjusts the sails. - John Maxwell
 
My fault. Didn't catch that part about not using web server languages. I've heard that Macromedia Dreamweaver can make a common menu that would do something like you want. I'm not sure of the details.

-Volkoff007
 
If your host allows you to use .htaccess files, you can use SSIs on any kind of page. See


for a tutorial.

Framesets have many disadvantages often discussed on this forum and elsewhere. Javascript would do the job, but only for people who surf with it switched on. About 10% of people surf without javascript, they're going to have trouble getting round your site if all the menus are produced that way.

My advice would be to go with SSI. It's straightforward, requires no programming - unless you want to - and doesn't depend on a particular browser set-up.

If you really want to preview your pages locally, you can set up a web server on your PC that'll process the SSIs. I don't bother - when I look at pages locally, I see them without menus and other common elements, just the content. That's all I need to check on that page anyway, I trust my SSIs to look after the menus etc. when the page goes live.

-- Chris Hunt
Extra Connections Ltd

The real world's OK for a visit, but you wouldn't want to LIVE there!
 
chrisHunt, thanks for your reply...but what do you see as the main disadvantages of framesets? In this day & age, who can afford to surf with an archaic non-frames compatable browser? What is wrong with a simple frameset that works well on all the major browsers from ie/netscape 3 onward?

As I see it, if you have a lot of heavy graphics in your top banner & left, the dialup users don't want to redownload/reload them for every page & anybody with broadband will surely have a compatable browser to match... maybe I'm missing something here...
 
redss,

If your images are repeated on each page then they should be loaded from cache, so it doesnt take any longer to load for the user.

Framesets and javascript bring in problems for search engines. If you create the navigation using js then you need to make a seperate section for search engines and this defeats the whole purpose of doing this in the first place.

Frames cause loads of problems, namely messing up bookmarking of a page and search engine spidering.

Hope this helps

Wullie


The pessimist complains about the wind. The optimist expects it to change.
The leader adjusts the sails. - John Maxwell
 
redss,

Your wrote:

"What is wrong with a simple frameset that works well on all the major browsers from ie/netscape 3 onward?"

You are absolutely correct. In fact framesets are more consistantly rendered than tables or css across different browsers. Loading from cache, although quicker than downloading, is not quicker than not having to re-load at all.

Framesets do not affect spidering at all.




Clive
 
CliveC,

I think you have been mislead, frames do affect spiders.

A spider treats each frame as a seperate document, afterall thats what they are. You can use noframes tags but again this defeats the purpose of this thread as this is about creating less work, not more.

Frames are useful on some occasions, but serving Internet content in frames to avoid having to recode between pages is pointless when you have scripting languages that can do it.

Also, what about the bookmarking issue?

Hope this helps

Wullie


The pessimist complains about the wind. The optimist expects it to change.
The leader adjusts the sails. - John Maxwell
 
A frame is no more of a separate document than a page that has a link to another page. They are all separate documents and spiders handle them equally well. The noframes tag has no practical purpose as all modern browsers handle framesets.

Scripting languages other than JavaScript only work from a server which was what the originator of this thread was trying to avoid.

As far as the bookmarking issue, framesets cannot be bookmarked in the conventional sense. However, as I have pointed out before, deep linking is not necessarily a good thing. Try doing a google search on "deep linking" and perhaps you will see what I mean.

Clive
 
CliveC,

Take the following scenario.

The content of the framed page (3 frames) is as follows:

--------------------------------
|1111111111111111111111|
--------------------------------
|2|33333333333333333333|
|2|33333333333333333333|
|2|33333333333333333333|
--------------------------------

Now, a spider hitting that page finds:

Page 1 = Content of top frame
Page 2 = Content of side frame
Page 3 = Content of main frame

Now, the exact same page as above using an include rather than a frame would mean the following:

Single Page = Spiders sees 1, 2 & 3 on the same page.

Now, anyone with even the slightest knowledge in search engine optimisation will know that there is no way in the above example that using frames is the same as an included page.

The noframes tag has no practical purpose as all modern browsers handle framesets.

I was talking about SE, not normal browsers, and a SE will read the noframes tag as it cannot render framed documents.

Deep linking might not always be wanted from other sites, but there is no reason to stop a user bookmarking a page. There is a huge difference between the two.

Sure, you might want a user to read a few other pages before they reach their destination, but there is no reason to stop them bookmarking that page because of course they had to go through the other pages already to get there.

Do you realise just how many people bookmark a framed page and end up at a content page with no navigation? If this happens, 99% of the time you will lose that visitor to another site. This is assuming that the frames are not used correctly, but on most smaller sites you will find this to be the case.

Hope this helps

Wullie


The pessimist complains about the wind. The optimist expects it to change.
The leader adjusts the sails. - John Maxwell
 
Iframes can be a compromise. With iframes used as the include mechanism, search engines and users can still bookmark a page, but you can maintain one nav file, banner file, etc, without relying on server-side logic, and no javascript.

-petey

News and views of some obscure guy
 
Wullie, The flaw in your argument is that a spider does not see a page comprised of three pages as a single page in the first place.

I could give you a practical example of a frameset site that I have, that has never been promoted by site submission, which has a top ranking, which would not be appropriate to deep-link to, and which any user would have no problem navigating.

Spiders do spider the single pages and report them separately on search engines, however each page is designed to load the frameset which is what any viewer would wish to see as the pages do not make sense on their own.




Clive
 
CliveC,

The flaw in your argument is that a spider does not see a page comprised of three pages as a single page in the first place

Thats not true. When I setup a page using includes to make up the example I showed above, there are 3 pages shown as 1. I don't see how you can disagree with this.

Spiders do spider the single pages and report them separately on search engines, however each page is designed to load the frameset which is what any viewer would wish to see as the pages do not make sense on their own

Simple question, what if the user has javascript disabled? What do they see? [wink]

Hope this helps

Wullie


The pessimist complains about the wind. The optimist expects it to change.
The leader adjusts the sails. - John Maxwell
 
Wullie, I meant that a spider does not see the framesets rendering as a single page. A frameset is a list of pages which do not know that they are in a frameset and indeed are just pages.

If I was concerned that users might have Javascript disabled I would simply place a link to the frameset in the individual page.


Clive
 
redss,

I had a problem like this and I solved it in a way that was very simple: I made the menu into a big GIF file and assigned an image map to it.

It appeared on every page, was cached in the first download, and when I changed the GIF, I changed the menu on all pages.

I used a product called Search and replace for Windows to make my changes to all my static pages. The site had about 300 pages to it. It would take me about an hour to make the new GIF, about twenty minutes to update a "test" page, about ten minutes to do a bulk search-and-replace, and about ten minutes to upload the static pages.

Maybe that'll help?

Cheers,


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top