Jump to content

Using 2 HTML Files In One Page

Whether you're a seasoned veteran or a struggling beginner, Web Radiance is the web development and web design forum for you. You'll find answers to all your HTML, CSS, SEO, and Programming needs. Pull up a chair and stay awhile.

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • This topic is locked

Using 2 HTML Files In One Page Rate Topic: ***** 1 Votes

#1 User is offline   GrantM 

  • W.R. Private
  • Group: Members
  • Posts: 14
  • Joined: 16-September 06

Posted 17 September 2006 - 04:13 PM

Iv yet to work out how to do this, but how do you use 2 seperate html files in one page?

Example: Iv got a menu bar i want to be on every page and everything can change.

Thanks

This post has been edited by GrantM: 01 April 2007 - 08:38 PM

0

#2 User is offline   sypher 

  • the owner3r
  • Group: Administrators
  • Posts: 1,578
  • Joined: 04-April 06
  • Location:North Wales, UK
  • Interests:Art, Boxing, MMA, Graphic Design, Web Design etc. ;)

Posted 17 September 2006 - 04:47 PM

This is done using includes, they can be done in mostly every language. The PHP one is:

<?php
include ("path/to/file.html");
?>
Meaning whenever you put that code in your page it shows that file in its place. You also have to save the page using this code as a .php extension.
sypher design - North Wales Web Design | Latest Work: - Scala Cinema

CSS - Can't See Sh*t
0

#3 User is offline   Catalyst 

  • Codesmith
  • Group: Administrators
  • Posts: 1,049
  • Joined: 04-April 06
  • Gender:Male
  • Location:San Diego

Posted 18 September 2006 - 12:46 AM

Yep, Server Side Includes is the full name. They're really easy to do whichever language you use.
0

#4 User is offline   James Mitchell 

  • Legendary
  • Group: Administrators
  • Posts: 922
  • Joined: 26-July 06
  • Gender:Male
  • Location:Fort Wayne, IN

Posted 18 September 2006 - 07:29 AM

If this were an answerable topic I would say it would be answered.

PHP Includes (or other languages) is one of the safest ways to use multiple pages of HTML (or code) and stuff it in many pages. Think of "navigation" (as in your case), "sidebar", or "footer" those things which are going to be on every page and updated frequently.
Posted Image
0

#5 User is offline   Ben Abrams 

  • The buddy system:never fails
  • Group: Administrators
  • Posts: 1,850
  • Joined: 04-April 06
  • Gender:Male

Posted 18 September 2006 - 09:47 AM

Ive edited this thread to be answerable.

May i just add, that on the nav page only put the html of the nav elements, dont add the html,head, or body tags.

otherwise you will get a mass of uneeded html.

for example:

the index page
<html>
<title>index page</title>
<head>
</head>
<body>

</body>
</html>


the nav page

<html>
<title>nav page</title>
<head>
</head>
<body>
<a href='#'>link</a><br />
<a href='#'>link</a><br />
<a href='#'>link</a><br />
<a href='#'>link</a><br />
<a href='#'>link</a><br />
</body>
</html>


Including the nav page into the index will do this....

<html>
<title>index page</title>
<head>
</head>
<body>
<html>
<title>nav page</title>
<head>
</head>
<body>
<a href='#'>link</a><br />
<a href='#'>link</a><br />
<a href='#'>link</a><br />
<a href='#'>link</a><br />
<a href='#'>link</a><br />
</body>
</html>

</body>
</html>

See all those duplicate tags. Not a nice idea. So make on your nav page JUST the links / images/ whatever...

Oh, and dont forget to select one of these posts as an answer to your problem..Just click the big button that says "this post answers my problem"

Posted Image


Read this thread for more information...

View PostSirkent, on 21 September 2007 - 04:26 AM, said:

<monty python high-pitched female voice>I DON'T LIKE SPAM!</monty python high-pitched female voice>
0

#6 User is offline   James Mitchell 

  • Legendary
  • Group: Administrators
  • Posts: 922
  • Joined: 26-July 06
  • Gender:Male
  • Location:Fort Wayne, IN

Posted 18 September 2006 - 01:08 PM

To further clarify and visualize what Ben was saying is the following is a breakdown of how the files should look as well as the final output:

The index page
<html>
<title>index page</title>
<head>
</head>
<body>
  <?php
	 include ("path/to/navigation.html");
  ?>
</body>
</html>

The navigation page
<div id="navigation">
  <ul>
	<li><a href='#'>link</a></li>
	<li><a href='#'>link</a></li>
	<li><a href='#'>link</a></li>
	<li><a href='#'>link</a></li>
	<li><a href='#'>link</a></li>
  </ul>
</div>

What your final page will look like:
<html>
<title>index page</title>
<head>
</head>
<body>
<div id="navigation">
  <ul>
	<li><a href='#'>link</a></li>
	<li><a href='#'>link</a></li>
	<li><a href='#'>link</a></li>
	<li><a href='#'>link</a></li>
	<li><a href='#'>link</a></li>
  </ul>
</div>
</body>
</html>

Posted Image
0

#7 User is offline   GrantM 

  • W.R. Private
  • Group: Members
  • Posts: 14
  • Joined: 16-September 06

Posted 01 November 2006 - 10:45 AM

The last post cleared everything up, thanks.
0

#8 User is offline   ShakingSpirit 

  • Pedantic Whinger
  • Group: Members
  • Posts: 237
  • Joined: 01-August 06
  • Gender:Male
  • Location:Southampton, UK

Posted 01 November 2006 - 01:20 PM

Just as a note, if you don't have a PHP-enabled webhost, you can do
<!--#include virtual="path/to/navigation.html" -->

and save your page as .shtml, to get the same effect ^_^
QUOTE(MSN)
Benbramz says: i had orgasmic thoughts at the excitement of that
0

#9 User is offline   ultra99 

  • W.R. Corporal
  • Group: Members
  • Posts: 95
  • Joined: 02-February 07

Posted 08 February 2007 - 04:01 PM

Umm, I'm really lost here. :wacko: How can I do this for the entire page? I want all of the pages to be the same as the home page, but with different text ofcourse.
0

#10 User is offline   Ben Abrams 

  • The buddy system:never fails
  • Group: Administrators
  • Posts: 1,850
  • Joined: 04-April 06
  • Gender:Male

Posted 08 February 2007 - 05:13 PM

then you make the homepage, and then in the include file you would put the text..

so your essentially, loading the text into the homepage

View PostSirkent, on 21 September 2007 - 04:26 AM, said:

<monty python high-pitched female voice>I DON'T LIKE SPAM!</monty python high-pitched female voice>
0

#11 User is offline   ultra99 

  • W.R. Corporal
  • Group: Members
  • Posts: 95
  • Joined: 02-February 07

Posted 09 February 2007 - 01:44 AM

What I thought is (and did in the past) is just copy and paste the code of the index.html file on every page, linking to the css file, and that's it.

But the includes and all that stuff, I really don't understand it. I'll probably do some reading about it.
0

#12 User is offline   Karl Buckland 

  • A.K.A. Sirkent
  • Group: Administrators
  • Posts: 2,145
  • Joined: 04-April 06
  • Gender:Male
  • Location:Kent, UK

Posted 09 February 2007 - 04:19 AM

View Postultra99, on Feb 9 2007, 06:44 AM, said:

What I thought is (and did in the past) is just copy and paste the code of the index.html file on every page, linking to the css file, and that's it.
You can of course do that, but as you know, if you then want to make a change to your HTML, you have to change every page to match.

Using includes allows you to have your HTML in seperate files, which get included into each main content file. So you might have your header, footer, etc, in seperate files and include them in the correect places in your content files. This way, if you want to change your HTML, you just go into your header file (for example), change the HTML, and because all the main files include it, they all show the change. You only need to change one file.
QUOTE(benbramz @ Aug 17 2007, 07:44 AM) Ive noticed that quite a few people are now adding quotes from the board into their signature. I think its started an new web-radiance craze.. :P
0

#13 User is offline   benbacardi 

  • Administrator
  • Group: Administrators
  • Posts: 1,140
  • Joined: 06-April 06
  • Gender:Male
  • Location:United Kingdom

Posted 09 February 2007 - 06:05 AM

See if this article helps you understand any more
0

#14 User is offline   TJSingleton 

  • Allegedly Legendary
  • Group: Members
  • Posts: 517
  • Joined: 31-July 06
  • Location:Winder, GA

Posted 09 February 2007 - 08:34 AM

You need a simple templating system then. How many pages are you looking to manage?
0

#15 User is offline   ultra99 

  • W.R. Corporal
  • Group: Members
  • Posts: 95
  • Joined: 02-February 07

Posted 09 February 2007 - 01:55 PM

I'm not really sure, around 10 maybe.
0

#16 User is offline   TJSingleton 

  • Allegedly Legendary
  • Group: Members
  • Posts: 517
  • Joined: 31-July 06
  • Location:Winder, GA

Posted 09 February 2007 - 04:23 PM

How likely are the pages to change? The reason I am asking is you may need a lightweight cms to handle this for you. If not I can extract a basic templating code from previous work for you to use.
0

#17 User is offline   ultra99 

  • W.R. Corporal
  • Group: Members
  • Posts: 95
  • Joined: 02-February 07

Posted 09 February 2007 - 04:37 PM

Not likely. Same layout, but diff text and images.
0

#18 User is offline   ultra99 

  • W.R. Corporal
  • Group: Members
  • Posts: 95
  • Joined: 02-February 07

Posted 10 February 2007 - 02:39 AM

View Postbenbacardi, on Feb 9 2007, 01:05 PM, said:

See if this article helps you understand any more


I did the steps but it turns out that my website doesn't support includes. But they say there's a solution to it, but i don't know how to do it.

When i preview the .shtml file in ff or IE, i get a message saying to download the file test.txt.

Quote

Enabling .shtml extentions
In the .htaccess file for your website, place the following code:
AddType text/html .shtml
AddHandler server-parsed .shtml
Save the .htaccess file on your server, and open the show.shtml webpage in a browser. This time it should work!

This post has been edited by ultra99: 10 February 2007 - 03:07 AM

0

#19 User is offline   Ben Abrams 

  • The buddy system:never fails
  • Group: Administrators
  • Posts: 1,850
  • Joined: 04-April 06
  • Gender:Male

Posted 10 February 2007 - 09:36 AM

thats the step. make a file, save it as .htaccess and add in it, those two lines..

AddType text/html .shtml
AddHandler server-parsed .shtml

View PostSirkent, on 21 September 2007 - 04:26 AM, said:

<monty python high-pitched female voice>I DON'T LIKE SPAM!</monty python high-pitched female voice>
0

#20 User is offline   marcamos 

  • W.R. General
  • Group: Administrators
  • Posts: 2,849
  • Joined: 04-April 06
  • Gender:Male
  • Location:Massachusetts - USA

Posted 10 February 2007 - 09:40 AM

I'm going to stray ever-so-slightly off topic here and suggest you begin looking for another hosting company. If your current host doesn't support includes, in this day and age, that is a sad sad thing. You can get great hosting for as little as three dollars a month, and I'm sure there are even other options out there that support includes and are free. But, I digress; let us know how this current solution that you're working on ends up going for you.
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users