...

View Full Version : My Layout HELP!



avatar.alex
01-07-2007, 09:10 PM
Im new at this php thing so sorry if this is a stupid question. Is there a way to change the layout on all the web pages without going to every single one to change it :confused:

Troy297
01-07-2007, 09:20 PM
Um.... well... I am asuming the site you are referring to is already made? If it is already made then no, but if it isn't then yes and it is really easy.

Simply make all your pages .php. Make your index page... then what you do is divide your page into 3 different parts... the part above the actual page content, the part below the page content, and the actual page content. Then what you do is you make a top.php, bottom.php, and whatever.php.

And in the top you but what is above your content in the layout, in the bottom you but what is below the content, and in the whatever you put....


<?php include('top.php');?>
Page Content Goes Here
<?php include('bottom.php');?>

So what our page will actually turn out like in our visitors browsers will be like this.....


<!-- Contents Of Top.php -->
<html>
<head>
<title></title>
</head>
<body>

<!-- Your Pages Main Content -->
Page Content Goes Here

<!-- Contents Of Bottom.php -->
</body>
</html>

Make sense? Lemme know if you dont get it... :D

avatar.alex
01-07-2007, 09:22 PM
but how would i know that the content would be where i want it to be and how would i divide the content up???

Troy297
01-07-2007, 09:22 PM
Sorry about that... I edited the last post - please re-read it!

avatar.alex
01-07-2007, 09:33 PM
im sorry but im new at this whole php thing if you could look at my other post and try to help me??? much thanks i kinda get it in a way

Troy297
01-07-2007, 09:35 PM
What other post do you mean? A link would be helpful! :p But to try and recap what I said more simply....

1. Design Your Page

<html>
<head>
<title>My PHP Website</title>
</head>
<body>
<div class="main">
This is my main content and other stuff....
</div>
</body>
</html>


2. Divide Up Your Code
Make A New File Called Top.php With The Following In It


<html>
<head>
<title>My PHP Website</title>
</head>
<body>
<div class="main">


Page Content

This is my main content and other stuff....

Make A New File Called Bottom.php With The Following In It

</div>
</body>
</html>

3. Create Your Php Page

<?php include('top.php');?>
This is my main content and other stuff....
<?php include('bottom.php');?>

To explain this step.... the "include('top.php')" means that within the page it will get the content of your top.php file and insert it into the top of your php file. The same goes for the "include('bottom.php')" except it includes your bottom.php file. When you design a layout this way it makes it so if you decide to edit your pages title attribute, you open the top.php file, edit the title, and it will apply to all the pages that have the "include('top.php')".

Hope this helps!

avatar.alex
01-07-2007, 09:39 PM
http://www.codingforums.com/showthread.php?t=104455 hahaha sorry:p



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum