Need advice.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jschner
Forum Newbie
Posts: 6
Joined: Mon Oct 07, 2002 11:52 am

Need advice.

Post by jschner »

I'd like to convert my site from individual pages to a shared header format similar to what this very forum uses.

I know very little about php and need to know is there an easy way to convert my site or would it be a very difficult thing to accomplish?

What would be the general steps and are there any templates or such out there I could use?

my site is located at http://www.cannondaler.com

Big TIA!
rev
Forum Commoner
Posts: 52
Joined: Wed Oct 02, 2002 3:58 pm
Location: Atlanta, GA

Post by rev »

You can probably find some 'templates' with a page layout using included headers and footers.

But, it's basic logic, so you can devise your own template with ease.

include() - http://www.php.net/manual/en/function.include.php
require() - http://www.php.net/manual/en/function.require.php

Code: Select all

<?php
require("/my/magic/header.php");

/* body content here */

require("/my/magic/footer.php");
?>
So, you may be wondering what goes in your header and footer. I cannot tell you everything, but I can make some suggestions.

I would go with the following items:
- page header, html, header, title, and body tags
- any repetitive data that you find yourself using over-and-over, etc...

Basically, use the header and footer to reduce redundancy on your site. Put content and data in these files that will make maintenance of your web site easier not more complicated.
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

to go a little bit further than rev did, lemme briefly explain how i do my sites. the basic layout for my site is this:

Code: Select all

<html>
<head>
<!-- headers -->
</head>

<body>
<!-- masthead (banner, top menu, other navigational stuff -->

<table>
<tr>

<td class="content">
<!-- this is the part of my site that changes from page to page -->
</td>

<td class="sidebar">
<!-- here i have a more complex menu system, user pannel, recent news, forums, etc. -->
</td>

</tr>
</table>

<!-- and here i put my copyright and other footer type material -->
</body>
</html>
so everything before my content area goes in to header.php and everything after it goes into footer.php and then each page looks like what rev posted. hope that helps.
jschner
Forum Newbie
Posts: 6
Joined: Mon Oct 07, 2002 11:52 am

Post by jschner »

Thank you very much. I can hardly believe I got my test file http://www.cannondaler.com/main.php running the first try.

Are you guys for real it's this easy? Anything I should watch out for or make sure I include when I convert all the pages on my site?

If I add a left hand menu is it better in with the header or on it's own in a file like leftmenu.php? Also for body alignment reasons does a leftmenu.php type file create a table and a body.php type file finish it?

Thanks again. My site is starting to seem fun again. :D
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post by Coco »

no its not really that easy :P
just your playing with some of the easy bits, if it were that easy there wouldnt be forums like this ;)

and as to having a leftmenu.php, its entirely up to you. personally it would depend upon whether you need to change it or not
eg...

Code: Select all

&lt;?php
if($user='admin')
  include leftadmin.php;
else
  include leftgrunt.php;
?&gt;

as always no syntax guarantee
Post Reply