View Full Version : How would I go about doing this?
groog
07-01-2007, 07:47 PM
Well I really want to make a way so that I can change the menu once in a separate file and it changes for all the pages so that if I want to change a menu item there isn't a lot of heartache. I've thought of several way of doing it with javascript, php, and html frames. Which would be best?
rafiki
07-01-2007, 07:50 PM
you could use php's include 'Menu_page.ext';
use that line on all pages you want to have the menu on and you update Menu_page.ext and it will change on the whole site which has the page on..
Jutlander
07-01-2007, 08:05 PM
The method suggested by rafiki is also the one I use on my site (which is currently in development). Just to concur... :)
groog
07-01-2007, 09:11 PM
Ok, I'll have to learn php though :P
CaptainB
07-01-2007, 09:16 PM
The include tag (or command?) isn't that hard - just like this:
<?PHP include("Menu_page.ext"); ?>
:)
Jutlander
07-01-2007, 09:20 PM
Ok, I'll have to learn php though :P
Not necessary.
<?php include("name_of_your_file.php"); ?>
Some notes:
The extension doesn't have to be .php. It can also be .html, .txt or whatever. Include() is a function in PHP and is quite simple. It just includes whatever file is specified within it. I keep all my includes in a separate directory so my includes look like this:
<?php include("include/name_of_file.php"); ?>
groog
07-01-2007, 11:13 PM
That will be helpful. But do I have to have a .php extension on the page for the include script to run?
Jutlander
07-01-2007, 11:14 PM
Yes... :) and that means the server must support PHP.
_Aerospace_Eng_
07-02-2007, 12:11 AM
Yes... :) and that means the server must support PHP.
While its good to have your pages have the .php extension for future expansion, its not all that necessary if your host supports php and htaccess. If it does then you can create an htaccess file that tells all .html and .htm pages to be parsed as .php
The only issue with this is if you are used to color coding syntax on your code some editors won't color the code properly because it still things its editing a .html page and not a .php page.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.