• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

PHP Navigation

pin0i

New Member
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
 
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?
 
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.
 
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.
 
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.
 
I have sample code...

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
 
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!
 
Back
Top