|
Posted by J.O. Aho on 07/14/07 03:10
John wrote:
> I would like to create a website with menus at the top and left side
> and with a background color. I have a template already selected. I
> would like to easily be able to had button or keep everything looking
> the same with the menus etc. What is the best way to go about that?
> Change the html extension to php and the have the php start and end
> command at the beginning and end?
Much depends on how you do thing, one way could be to make a script to do one
thing, like one for menu, one for footer, one for random banner.
Then in the main pages, you "include" those "modules" for example
--- simple index.php ---
<html>
<head>
<title>index.page</title>
</head>
<body>
<?PHP include "banner.php"; ?>
<div class="right">
Some text
</div>
<div class="left">
<?PHP include "menu.php" ?>
</div>
<?PHP include "footer.php"; ?>
</body>
</html>
--- eof ---
At least if you have large amount of HTML, don't echo it out, just use an
end-tag for php and let it be as normal and when you need to use php again,
then use an start-tag.
> And then is best to use require
> rather then the php include command?
It depends on how important that the "included" php is, it it's possible to
use the page without the "include" then use the include function, but if the
"include" is needed to be able to show page, then use require function.
For example, if it's more important to show the content of a page than the
menu itself, then use include function.
For example you have a made your own functions, stored those in a php-file and
you use those functions in your page, then use require function, as you won't
be able to show the page without those functions been loaded.
> Also does the php command go at
> the start before any html?
If you want to send HTTP-headers, cookies or sessions, then you should do
those calls first, before any output from the "page". Otherwise it don't
matter if you start in the top, somewhere in the middle or at the end.
--
//Aho
Navigation:
[Reply to this message]
|