hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Web Design and Content : About this Code
Reply

Web Design and Content Subjects include, HTML, graphics, editors, CSS, Flash, graphics creation, placing of ads, ad serv companies, copyright, content and nearly anything else design related. Also talk about businesses that provide design services. If you link to your site, you must post in Web Site Reviews.
Forum Jump

About this Code

Reply Post New Thread In Web Design and Content Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 12-22-2005, 08:21 PM
Einstein500 Einstein500 is offline
Newbie
 
Join Date: Dec 2005
Posts: 12

About this Code


Quote:
Originally Posted by the_pm
Includes are the way to go. The three most common methods are PHP, ASP and SSI (though SSI is rapidly losing popularity, in my observation).

The whole idea of an include is easy. You put a single line of code into every page, like this:

Code:
<?php include "path/include_file.inc";?>
And then you create an entirely separate document with the information you want to insert, in your case, navigation. Now, when you want to make a site-wide change, you change that one file, and the whole site updates.

You can take this a step farther by putting includes inside included files. I'll personally create subsection navigation for a site, put each subsection in its own include file, and call it into a page for displayed navigation, DHTML menus, the domain's site map, etc., all controlled from a single source. It saves a TON of time, and you can put together a really slick system!
I have seen this posted alot, but where exactly would you put it?..does it matter or can it be in any place of the coding? Also, about that separate document you create, how do you set it up? Like how would it link?...Thanks for your time.

Einstein

Reply With Quote


Sponsored Links
  #2  
Old 12-22-2005, 08:27 PM
Dan L Dan L is offline
Web Developer
 
Join Date: Feb 2003
Location: Connecticut
Posts: 5,441
The file needs to be a .php file, and you can put it anywhere. You usually place it where the content from the included file would go.

The separate document is just a normal file.

Say I had an about me page and wanted to include a header & footer.

index.php
Code:
<?php include 'header.html'; ?>
Hi!  My name is Dan.  I'm a programmer.
<?php include 'footer.html'; ?>
header.html
Code:
<html>
<body>
footer.html
Code:
</body>
</html>
When you're done, the resulting page will look like:

Code:
<html>
<body>
Hi!  My name is Dan!  I'm a programmer.
</body>
</html>
Does that make sense?

Reply With Quote
  #3  
Old 12-22-2005, 08:37 PM
Einstein500 Einstein500 is offline
Newbie
 
Join Date: Dec 2005
Posts: 12
Ya, sort of...I am still a little confused about where to put it.

Reply With Quote
Sponsored Links
  #4  
Old 12-22-2005, 10:10 PM
DWS DWS is offline
WHT Addict
 
Join Date: Aug 2002
Location: California
Posts: 109
Quote:
Originally Posted by Einstein500
Ya, sort of...I am still a little confused about where to put it.
You'd put it inside a .php file.

Look at DanX's first example of code (index.php) - that is a small but complete file. You'd simply add more to yours.

To view the contents of that file, you'd go to http://yoursite.com/index.php assuming your server supports PHP (most do).

Reply With Quote
  #5  
Old 12-22-2005, 10:17 PM
Dan L Dan L is offline
Web Developer
 
Join Date: Feb 2003
Location: Connecticut
Posts: 5,441
The code is like a substitution for other code.

In math, say you have something like

x = 1 + 2
y = 1 + x + 3

From that, you would make

y = 1 + 1 + 2 + 3

An include works the same way. x is the include and y is the initial page. You're simply taking content from one page and putting it in the other, exactly where the code is.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Cloud Industry Forum Establishes Cloud Service Provider Code of Practice Web Hosting News 2012-09-21 12:38:23
DigiCert Launches Extended Validation Code Signing Certificates Web Hosting News 2012-08-15 15:30:28
Non-Profit New Zealand Computer Society to Develop Cloud Code of Practice Web Hosting News 2011-09-02 17:22:36
SSL Certificate Authority Comodo Providing Intel Application Certification Web Hosting News 2011-08-12 15:51:28
Web Host DreamHost Contributing Code for Ceph File System to OpenStack Web Hosting News 2011-06-23 20:40:32


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?