FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Server Side Include (HTML in HTML)






Is SSI good for creating HTML?
Yes
60%
 60%  [ 3 ]
No
40%
 40%  [ 2 ]
Total Votes : 5

gr8ankit
Hey guys i am developing a site in which i want the main logo & the navigation bar & the side menu to be the same in all the 100 's of pages i will write. (This is because i have to add a new topic everyday!.)

The steps i took :
1. I used dreamweaver to build this project.

2. I created a file :-
Quote:
a.shtml
in which i wrote html containing header, menu, navigation bar,etc.

3. Now i included the a.shtml file in a sample file, say
Quote:
sample.html
.

To do this i gave the following code in the head of sample.shtml.
Code:
 <!--#include virtual="/a.shtml" -->


It worked & the contents of a.shtml can be viewed in sample.html (only in dreamweaver not in browser because SSI cammands dont work with any browser)

The tragedy begins

4. Now i want to edit sample.html further containg the details of the product.

But i was not able to do this.


What i want from you

1. Is thr any other way for keeping my menu navigation, haeder same throughout the site

2. Can we preview the ssi pages is brower

3. Why i am not able to edit sample.html further.
Diablosblizz
If your host supports php (Frihost does) then you should use this:
Code:
<?php
include('FILENAME.html');
?>


This will include everything in the file. For example:

In FILENAME.html I have:
Code:
HI!


then the place where you put that code would have somewhere:
Code:
HI!
.
sonam
PHP is not good to include full HTML in other HTML because in that case you will have doubled tags (HTML and BODY) what is not good type of coding. I am prefer iframe for HTML pages and PHP for PHP or part of HTML code (but not full).

Code:
<IFRAME NAME="someName" WIDTH="500" HEIGHT="50" MARGINWIDTH="0" MARGINHEIGHT="0" SRC="someFile.html" SCROLLING="no" FRAMEBORDER="no"> </IFRAME>


Sonam
Diablosblizz
Ah yes, totally forgot about the Iframe. Yah thats also possible. Thanks for reminding me.
gr8ankit
ya thank you all but is thr any way to see included pages in any browser.

And my second question :- is it possible to maintain menus & header by any other way!
gr8ankit
I frame canot be use for menu! Because when we include a menu using i frame, & when some1 click on the link in menu that page gets open in the frame only, not on the browser!
sonam
A am not sure but this problem is in target. Try in menu for <a > definition set:

target = "_top"

Sonam

P.S.
You don't need big reed letters for your questions.
welshsteve
gr8ankit wrote:
I frame canot be use for menu! Because when we include a menu using i frame, & when some1 click on the link in menu that page gets open in the frame only, not on the browser!


You should be careful about using an iframe to display a menu, particularly as if the menu has drop downs, the dropdown will not appear outside the confines of the frame it is placed in. This is a classic case for using SSI.

HTML PAGE WILL BE SOMETHING LIKE THIS
Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Strict</title>

<meta http-equiv="Content-Type" content="text/html; charset=shift_jis" />
   
<link rel="stylesheet" href="style.css" type="text/css" />
   
</head>

<body>

<div id="header">
   Header
</div>
<div id="nav">
   <?php include("nav.php"); ?>
</div>
<div id="content">
   COntent
</div>

</body>
</html>


and your nav.php page will be something like this
Code:

<ul id="nav_list">
     <li><a href="home.html">Home</a></li>
     <li><a href="about.html">About Me</a></li>
     <li><a href="stuff.html">Stuff</a></li>
     <li><a href="contact.html">Contact</a></li>
</ul>
mathiaus
I believe the page from which you are including files from (sample.html), requires a .shtml suffix.
welshsteve
mathiaus wrote:
I believe the page from which you are including files from (sample.html), requires a .shtml suffix.


I didn't know that I have to say. I though you could include any type of file, including simple text files. Having said that, I've only actively used ASP SSIs as I have never had a host that supports PHP before.

I don't like using iframes for including in this way, mainly because of the cross browser issues with setting zero borders on an iframe.
sonam
Code:
2. I created a file :- Quote:
a.shtml 
in which i wrote html containing header, menu, navigation bar,etc.

3. Now i included the a.shtml file in a sample file, say Quote:
sample.html



gr8ankit didn't exactly explain what hi/she want. Of course if he/she have drop down menu it is not good to use iframe. I have idea that he/she want to include full html page in other html page (template). Shocked

Sonam
lukeropro
sonam wrote:
PHP is not good to include full HTML in other HTML because in that case you will have doubled tags (HTML and BODY) what is not good type of coding.


I use the php include function and there is no problem at all. If you don't want doubled tags just code the included file in php
sonam
Quote:
I use the php include function and there is no problem at all. If you don't want doubled tags just code the included file in php


I know it is possible to include part of HTML to another page without any problem, but gr8ankit asking for including full HTML page (how I understand his question). Confused If I am wrong, sorry... Wink

Sonam
welshsteve
There shouldn't be a problem having "double tagging" as you call it, because in the page itself, only the iframe tag will show. That really isn't anything to worry about
Diablosblizz
Also, I usally never include my <body> and <html> in my .php codes, thats if im using
Code:
<php include('filename.php'); ?>


I don't think this really makes a difference. But, my php codes work anyways.
gr8ankit
Hey thank you all. I read all the topics, now i got the final solution to it.
My problem was updating the navigation bars! I solved it by making them in flash, now i dont need the above techniques. Now if i want to update my menus, i just have to upload the swf file to the server & all my pages will be updated with a sin gle file. Still very thankful to you all.
gr8ankit
thnx!!!!!!!!!!
Related topics
HTML
Do you use dreamweaver for web design.
How to use SERVER SIDE INCLUDES
Server Side Includes
Favorite CMS.
Page cache/refresh question
Center the site with the <DIV> tag.
Navigation Bar Updates in HTML
Server side included footers and the like.
server side includes SSI + stats
Are there any installed apps on server side?
Server Side Redirects vs. META Redirect?
Use of Server Side Includes on frihost
Need advice for those with Online Retail design experience.
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.