If you are new to domains and looking to buy, sell and learn about domains then you have come to the right place. DNForum is the largest domain name community on the internet and continues to grow every day. There are over 105,000 domainers on DNForum doing everything from buying domains, selling domains, learning about domains and discussing domains. Take a minute and Register.
Register Today on DNForum IT'S FREE!I am wondering, what is the best way to design a website that has some areas of static content that show up on each page such as a site navigation menu or a page footer that contains a disclaimer and links? The information on the menu and footer would never change from page to page, only the rest of the page content.
From my understanding, I want to stay away from frames. So how would I go about doing this? Should I put the menu and footer in spererate php files and use includes on each page to call them in? Or is there another way to go about this. I just want to make sure I get most of this right so I don't have to 1 day open up 500 files just to make a minor change to the dislaimer or copyright info on each page.
Your help is greatly appreciated. Example are helpful if possible. Thanks.
WorldNewsForum.com - General Discussion Forum
FightForum.com - MMA, Boxing, UFC, and More - Discuss Boxing and MMA.
Php includes for the header and footer are probably your easiest and fastest way to get this job done. You could have a 50,000 page site, 1 header, 1 footer and it's simple to change the layout/menu once and be done with it.
An example page is below. Page is named index.php
<!DOCTYPE><html><head><title>title goes here</title>
<? include('head.txt') ?>
put your body html here
<? include('foot.txt') ?>
head.txt would just contain the rest of your header, the main menu and opening tables etc.
foot.txt would contain the closing tables and bottom of your page.
Thanks for the reply. I was thinking along those line but just wasn't sure. I guess I am confident enough to go mess around with it now. Wish me luck =)
WorldNewsForum.com - General Discussion Forum
FightForum.com - MMA, Boxing, UFC, and More - Discuss Boxing and MMA.
Good luck
One thing you may need to know, depending on your system you may have to include the path to the include. Try not to use the URL to the include however even though that may be easier. /home/username/public_html/folder/head.txt (or whatever your path is) is the best.
The first time I ever tried to create repeating elements in a web site, I really screwed up and used a JavaScript file. Since learning a bit of PHP, I'll never go back to the old way of doing things again.
Good luck.
--- C0113c70r
Hi, I suggest using
<?php
include "file.php";
?>
instead as ) is not really needed.
Include is definately the simplest, you could do a SSI if you have no other need for php.
A simple template engine is also an option, if you want to generate static pages
imho, the best way to have a PHP template so to speak is to make your repeatable page... name it "template.htm", and put "##content##" where you want the changing content to be.... then you can make each individual page as another file "aboutus.htm". Then on a PHP page you can do this:
Viola... PHP (in 1 line) has now sucked the aboutus page into the space where ##content## is on the template page. You have now taken your first step towards proper templating and seperating your code from your design.<?
echo str_replace('##content##',file_get_contents('about us.htm'),file_get_contents('template.htm');
?>
NIce tip mike, thanks
Ah mike that is not really a good way... just make it use an OOP template parser...
Bookmarks