View Full Version : Html = Insert
Hello,
I am creating a table of content for my website. My friend told me of a way I could create it, so when I change the link page, it will change on every page because you inserted the code. I am wondering what code would have to write to have my content page, show up on my maine pages?
Hope this is not to confusing.
I belive you are referring to Server Side Includes (SSI). You can use this to take all content from page links.html and insert it into the current page.
<!--#include file="links.html"-->
If you are on a linux system, make sure any html pages with this code in them are named .shtml instead of .html
Chicken
08-22-03, 07:25 PM
I *think* (and to be honest I'm not 100% certain what you're asking exactly), that you're talking about either php includes or SSI (server side includes). In case you are:
SSI:
http://www.netart.it/manual/howto/ssi.html#basicssidirectives
http://www.bignosebird.com/ssi.shtml
http://www.apacheweek.com/features/ssi
Etc.
PHP Includes:
http://www.hardcoder.com/scripting/php/include_files.php
http://www.developerfusion.com/show/1826/2/
Which is better? (Note that the user refers to SSI as 'HTML includes)
http://jimworld.com/apps/webmaster.forums/action::thread/thread::1046531420/forum::php/
Some of these links aren't the greatest, but they do give you the basic idea, plus you can search for terms like 'SSI' or 'Server side includes' or 'php includes' (etc.) to find additional info. If this isn't what you wanted, can you please restate the question?
EDIT: Mark beat me to it. In reality, if that's all you wanted, you can just use the info he posted. Nothing wrong with simplifying life ;) :D
php includes is an easy way to go as i use them a lot on a site i run, I had the site made for me but once i understood the basics of the php code used in there i was able to add pages and what not. i dont remember the coding for it off hand but look at some of the sites checken linked on this thread and you should be able to get it farly easly.
PHP include() would be my recommendation. Just be careful to hard code the links as much as possible.
i.e.
<?php
$inc_page = $_GET["var"];
include($inc_page);
?>
is insecure since anyone could manipulate the GET variable 'var' and insert a suitably evil piece of code onto your server (include() will allow remote file paths).
A better way would be to:
<?php
$inc_page = $_GET["var"];
switch ($inc_page);
{
case "option1":
include("option1.php");
break;
case "option2":
include("option2.php");
break;
default:
include("index.php");
break;
}
nameslave
08-23-03, 02:24 AM
Originally posted by exasko:
Hello,
I am creating a table of content for my website. My friend told me of a way I could create it, so when I change the link page, it will change on every page because you inserted the code. I am wondering what code would have to write to have my content page, show up on my maine pages?
Hope this is not to confusing.
I guess your friend is probably talking about PHP Includes which are really simple to do:
1. First, you need to create an include file and name it as e.g. toc.inc (or whatever.inc); use a simple .txt file and rename it as .inc. Copy and paste or write your navigation (i.e. table of content, if I get it right) links onto it in HTML.
2. Then insert the following codes at the place where these links are supposed to be:
<?PHP include('toc.inc'); ?>
where toc.inc is your Includes file name.
3. Finally rename your web page (from either .htm or .html or whatever) to .php (e.g. index.php) and you're done! Of course, make sure your host supports PHP at no extra cost, or you may want to switch hosts. Hope this helps.
P.S. The best thing about PHP Includes is that they could be used not only for navigation but nearly everything on your page which asks for site-wide modifications. Now most of my web pages are filled with PHP include tags. And if you're like me, you may actually create a sub-directory (/includes) to house all those .inc files.
you may actually create a sub-directory (/includes) to house all those .inc files.
I presume you are either interpreting all .inc files or they are really .inc.php?
nameslave
08-23-03, 01:58 PM
Originally posted by S3G:
I presume you are either interpreting all .inc files or they are really .inc.php?
If I understand your meaning correctly: I usually put .inc files (such as navigation.inc, footer.inc, etc.) in a sub-directory named /includes for organization purpose (just like some use an /image or /img sub-directory). But you may want to make sure calling up "/includes/whatever.inc" in your PHP tag.
Hope I have only made things clearer instead of vice versa. ;)
Thank you for all your help
real quick... the .inc files, can i code those in html simply, with some javascript.. or does it have to be php?
nameslave
08-29-03, 07:40 AM
I use plain HTML. Haven't try any javascript as most of my .inc files are small with only text and hyperlinks.
vBulletin v3.5.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.