View Full Version : PHP Navigation
pin0i
December 25th, 2000, 20:42
I'm a newbie in php. On my site, I have a navigation on every page. So whenever I edit one thing on it, I have to go edit ALL the other pages. My friend told me I could use a php script to call a file on my server that has the code for the navigation in it. So I would only have to edit that single file instead of going through every page. Is it possible? And does anyone have the script?
Thanx
Koolguy
December 25th, 2000, 21:52
It's very possible, try this code.
<?include('http://www.somesite.com/somefile.inc'):?>
pin0i
December 25th, 2000, 22:18
quick question...
if you have a php script in your coding, should the extension of the html file be changed to .php or .phtml...or just keep it regular?
Nick
December 25th, 2000, 22:23
You'd have to ask your host. If it's PHP3 the extension would prolly be *.php3 possibly .php, but if it's PHP4 it could be *.php or *.php4, and *.phtml could be either one. It's kind of hard to tell. You could either ask your server admin/support or use a .htaccess file to set the file extension.
Daniel Crabtree
December 26th, 2000, 14:59
There is another alternative as well,
If you simply want to make changing the navigation simplier.
You could use SSI (Server Side Includes). You need to change any page that uses them to .shtml and make it include a file using
<!--#include virtual="/somedir/somefile.txt" -->
You can also include .cgi files, or anything like this.
Or you could make all your files .php, .php3, .php4, .phtml or whatever you need to make them and then use
<?php
virtual ('=/somedir/somefile.txt');
?>
If you put that code in, you don't need to change any of the rest of your HTML code into echo's.
The simplist way is to use the SSI method, but some hosts donot support that, but if they don't support SSI they probably won't support PHP either.
jvv
December 28th, 2000, 08:28
In php either
include("filename.ext"); or require("filename.ext"); will do. Note that the second one will mainly be used if the filename.ext has php code in it. No need to use the virtual stuff.
RNilsson
December 30th, 2000, 13:56
I have some sample php-code that i use on my site, with an external menu-file.
If you contact me via e-mail: lstrike@hem.passagen.se
or icq: 3941368 and i'll can share the files with ya, if ya want.
//Richie
Jonathan
January 5th, 2001, 05:33
OK, I have the same problem than pin01 and I have used SSI code to solve it. I have used this code:
<!--#include virtual="/somedir/somefile.txt" -->
I have also renamed my file to *.shtml and I have opened it using Internet Explorer and I works!! I solves the problem. However, when I try to open it on Netscape Navigator, the file won't open and will make my site save the file as nameofthefile.exe. I need your help!
THANKS!
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.