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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server Side Includes 1

Status
Not open for further replies.

purpleski

IS-IT--Management
Aug 14, 2002
112
FR
Hi

I want to convert my current site to a frameless site but of course the usability that frames gives. I have therefore constructed the basic menu page an example can be seen at
This then needs to be inserted on every page such as at The extension is currently shtml because the server is not set up to parse htm pages but will, hopefully, when the conversion takes place.

What I want to know is whether SSI's in the form:

<!--#include virtual=&quot;menu.htm&quot; -->

are the best/only way to go for this or should I be looking at some other way (PHP/ASP - both of which I don't have a clue about)?

Any thoughts examples would be welcome.

Regards
 
Codepoet

Thanks for the reply but

How about CSS? Using standard CSS

is too cryptic for how does that work?

Regards

 
No one seems to want to help this guy with what he wants. Why is that?

frozenpeas
 
frozenpeas you are right. I still love these forums I use a lot of them because I am amateur but enjoy doing these things myself but sometimes I find it very difficult to get the answer I need.

I assumed that this would be something that many people would like to know the answer to. All over the web there are 1000's of sites where each page has a menu and a footer and I just want to make sure before I go to the trouble of re-writing to some extent all 300 pages of my site that SSI's are the best/simplest/recommended way to do this?

That is all.

Regards

 
I'm not sure I understand your problem. Your menu is already in an external javascript file which is included on the pages by one of these lines

<script language=&quot;JavaScript1.2&quot; src=&quot;coolmenus4.js&quot;></script>
<script language=&quot;JavaScript1.2&quot; src=&quot;cm_addins.js&quot;></script>
<script src=&quot;menu.js&quot; type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;></script>
not sure which is your menu

and then called onto the page by a function,
<script type=&quot;text/javascript&quot;>FunctionName()</script>

The real problems with javascript included menus is that spiders do not activate javascripts so will have no navigation to follow and approx 10% of visitors have javascript turned off or are using non-java browsers

you have more problems on that page with the extra <head>, <body> and <html> tags littered about the code as well.

If you want to use SSI or scripting to include navigation it will depend on what server side scripting your host supports



Chris.

Indifference will be the downfall of mankind, but who cares?
 
Chris

Thanks for that. That was a real case of me getting fixated on a problem and not seeing the wood for the trees. It works just inserting the external js script into each page.

But as you say not very friendly to search engines. I think I may do a search on menu systems and the best way of designing those into a site but whatever you answered my questions.

Thanks.

 
You have a stack of HTML pages with some content that's common to all of them. How do you fix it to store the common content in one place and reference it from each page? Several answers, pick one you like...

External Javascript file

eg: [tt]<script language=&quot;JavaScript1.2&quot; src=&quot;menu.js&quot;></script>[/tt]

The script in question outputs the necessary content to that point in the document. This is a straightforward technique that does not require any special facilities on the server. If your Javascript is up to it, the scripts can be as sophisticated as you like.

The major disadvantage of this approach (and it's a biggie!) is that not all surfers have Javascript switched on - these people won't see your common content at all. Included in the Javascript-challenged are most search engine spiders, so if you rely on this method to display your navigation menus there's a good chance that many of your pages will not make it into search engines.

For this reason, I recommend you not to use this method for critical content. It is useful for content that itself requires javascript to work. On for example there's a drop-down box that only appears if you have javascript enabled. It could have been included in plain HTML, but since it only works if javascript is switched on it's a handy method for hiding it from luddites and spiders.


Server Side Includes

These are instructions to the web server to include the contents of a particular file at a particular place in a served document. The file in question can actually be the output of an executable script in your cgi-bin rather than a fixed file if you prefer.

Processing SSIs adds an overhead to the serving of files, as the web server has to parse the HTML file for SSI instructions before it serves it. This is one of the reasons some providers (especially free ones) do not permit you to use SSIs. It's also why most servers are set up to look for a special extension - generally .shtml - to distinguish files which need to be checked for SSI commands from those that don't. You can, however, force the server to parse all files by putting appropriate instructions in a .htaccess file.

The big advantage of SSIs (and other server-side solutions) is that the page your visitor sees is pure (X)HTML, the browser (or spider) has no extra work to do, and is unaware that parts of the page it's looking at were generated by SSI. See faq253-3309 and faq253-2000 for more information on SSIs.


ASP, PHP, etc.

I've not used ASP or PHP, but my understanding is that they're programming languages that allow you to embed scripts and instructions into HTML pages (or chunks of HTML into your scripts, if you prefer to think of it that way!). As such they're more powerful than plain SSI, but potentially more complex too. Again there's a small overhead in serving this type of file, again not all providers allow it. These approaches share the advantage of looking like plain HTML to the browser.


CSS

Not sure whether this is what iSeriesCodePoet is driving at, but you can (in theory) use the CSS2 [tt]content:[/tt] property to define limited standard content from within a style sheet. You can read more at .

Like Javascript, CSS relies on the client being able to do the work. AFAIK no current browser properly implements the content: property.


Other Approaches

If you're using Dreamweaver, I believe you can create template documents that generate your .htm files with the standard content in place. If you change the standard content, you have to re-generate the .htm files and upload them all to your server, but this approach has the virtue of requiring no special facilities on the server, and no extra overhead when serving the files.

Another approach might be to use images and server-side image maps, though this method has significant drawbacks with accessibility and should be used with caution.


Conclusion

&quot;What I want to know is whether SSI's ... are the best/only way to go&quot;

Not the only way to go, but certainly one of the best.

-- Chris Hunt
 
While pondering this problem the other night, I came up with one of the easiest solutions, which I'm sure is heavily in use...

Put the common code between html comment tags
Code:
<!--- navigation --->
lots of html... la de da
<!--- end navigation --->

Then throw together a quick script in your language of choice to just whip through all your html files and replace everything inside those tags with the new source you provide it... simple, and if you don't write scripts there're plenty of third party products out there which can handle this.

Personally I use the PHP solution more often than not, but when I have a page setup which requires no PHP, I hate to add it in just for this one purpose.

-Rob
 
A big thank you Chris Hunt for your comprehensive reply.

Regards.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top