Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

using a menu in multiple pages
I am want to use a menu in all my web pages.
So when I replace the menu for another
I would like to see all the other pages change too.

In C I could use an include in the preprocessor stage.
Is there something in PHP or html?

Report this thread to moderator Post Follow-up to this message
Old Post
fed
04-15-05 08:56 PM


Re: using a menu in multiple pages
"fed" <u@dds.nl> wrote in message news:c_N7e.3531$HP5.2080@newsfe01.lga...
>I am want to use a menu in all my web pages.
> So when I replace the menu for another
> I would like to see all the other pages change too.
>
> In C I could use an include in the preprocessor stage.
> Is there something in PHP or html?

In php there is. Magically it's called include.
<?php include "my_menu.txt"; ?>


Example.php:
<html><head></head>
<body>
<?php include "my_menu.txt"; ?>
Blaah blaah bblaah
</body>
</html>

my_menu.txt:
<p>Here's my über menu</p>


--
Welcome to Usenet! Please leave tolerance, understanding
and intelligence at the door. They aren't welcome here.
eternal piste erection miuku gmail piste com



Report this thread to moderator Post Follow-up to this message
Old Post
Kimmo Laine
04-15-05 08:56 PM


Re: using a menu in multiple pages
fed wrote:

> I am want to use a menu in all my web pages.
> So when I replace the menu for another
> I would like to see all the other pages change too.
>
> In C I could use an include in the preprocessor stage.

You could...but you shouln't.

> Is there something in PHP or html?
Yes, both.

RTFM http://uk2.php.net/function.include

C.

Report this thread to moderator Post Follow-up to this message
Old Post
Colin McKinnon
04-15-05 08:56 PM


Re: using a menu in multiple pages
On Fri, 15 Apr 2005 13:56:51 +0200, fed wrote:

> I am want to use a menu in all my web pages.
> So when I replace the menu for another
> I would like to see all the other pages change too.
>
> In C I could use an include in the preprocessor stage.
> Is there something in PHP or html?

You want a common piece of code to be run on all the pages of your
application, and you want to be able to modify this code in only one
centralized location, so that the modification will then occur for your
entire application. Is that what you wish?

You can do this with PHP.

Create a function, or a class, which produces the menu, and call this
function (or instantiate the class) on each page where the menu is to
appear. Put the function (or class) in a php file of its own, along with
other common functions and classes. Then "include" this code in any php
script which needs it with a require statement (require $filename where
$filename is the name of the file, and possibly its path if not located
where expected by php). If your code is very complicated and you start to
have problems including the same files multiple times (giving you errors),
you could use require_once instead.

To make changes, you can edit the function or class. Or you can make the
function or class be dynamic, by having it determine its output (i.e. its
generated html code) based on for example reading another file with a
require statement (this time perhaps only text), or a switch statement (if
you have set types of menus you want to always choose between) or from a
database. This latter really gives you full flexibility of what you can do.

Report this thread to moderator Post Follow-up to this message
Old Post
coolsti
04-18-05 01:55 PM


Re: using a menu in multiple pages
On Fri, 15 Apr 2005 13:56:51 +0200, fed wrote:

> I am want to use a menu in all my web pages.
> So when I replace the menu for another
> I would like to see all the other pages change too.
>
> In C I could use an include in the preprocessor stage.
> Is there something in PHP or html?

You want a common piece of code to be run on all the pages of your
application, and you want to be able to modify this code in only one
centralized location, so that the modification will then occur for your
entire application. Is that what you wish?

You can do this with PHP.

Create a function, or a class, which produces the menu, and call this
function (or instantiate the class) on each page where the menu is to
appear. Put the function (or class) in a php file of its own, along with
other common functions and classes. Then "include" this code in any php
script which needs it with a require statement (require $filename where
$filename is the name of the file, and possibly its path if not located
where expected by php). If your code is very complicated and you start to
have problems including the same files multiple times (giving you errors),
you could use require_once instead.

To make changes, you can edit the function or class. Or you can make the
function or class be dynamic, by having it determine its output (i.e. its
generated html code) based on for example reading another file with a
require statement (this time perhaps only text), or a switch statement (if
you have set types of menus you want to always choose between) or from a
database. This latter really gives you full flexibility of what you can do.

Report this thread to moderator Post Follow-up to this message
Old Post
coolsti
04-21-05 01:56 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:15 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.