PDA

View Full Version : Php Layout Help?


famazingspacedotcom
July 26th, 2008, 03:47 PM
I am opening up a new website/well I've had it for awhile, just havnt gotten around to setting it up/ but anyways, I want to make it 3 columns, but everything I try doesn't work, it usualy causes the right column to float around. Does anyone know how to make 3 columns work in php? Or is there a better way to do it rather then using php? I would appriciate the help :)

Smurfwicked
July 26th, 2008, 03:57 PM
My suggestion is before implementing any php whatsoever layout out your design first! That will keep everything on 1 file for testing the layout structure.

Once you've got the design how you want it then we'll start with making it work with includes.

So for example make a layout.html file that includes all everything! Once you have that looking the way you want do this.

Copy the section of code for your header. Make a index.php file, make a index.php file use the php include for a file called header.php, now make a header.php file and paste the header code from your layout.html file. do the same thing for right nav, left nav, content area, and footer. Does that make sense?

Thats how I do it and works good for me. A lot of times I don't feel like adjusting divs so I search for a basic template that only provides structure of the design without any images or details.

famazingspacedotcom
July 26th, 2008, 04:44 PM
once I have everything in the right file/ header.php footer.php etc./ how do I insert the includes?
blah I'm almost tempted to just buy/trade for a layout. lol how much would that cost me?

geg2
July 26th, 2008, 05:22 PM
PM me your email address and I'll send you a couple example files.

Smurfwicked
July 26th, 2008, 05:36 PM
Ok I'll use this for example:

You've removed your header code from the index.php file and placed it in a header.php file, where the header code once was in the index.php file place this code there:
<?php include('yoursitepath/header.php'); ?>

Actually to make it easier you might want to use $rootbase since you'll be using the theme in a lot of subfolders this will tell it always go back to your root directory because it naturally will want to follow the path from within the folder unless you place the full path in the include:

Explaination:
Full path example:
<?php include('http://mysite.com/theme/header.php'); ?>
What is best to use:
<?php include($rootbase . '/theme/header.php'); ?>

^ In other words use that, I put the other examples there thinking it might help you understand how it works.

Depending how extensive you get you might want make a configuration file and have a include in your header like so:
<?php include($rootbase . '/config.php'); ?>

This would be good for holding key information site wide in the form of variables which also makes for smaller file size. for example:

Your header has this in it:
<title><?=$sitename?> - <?=$title?></title>
<meta name="description" content="<?=$description?>" />
<meta name="keywords" content="<?=$keywords? />

And you config.php file has this in it:
<?php
$sitename = mysite.com
$title = myspace layouts, graphics, and generators
$description = the best myspace resource site
$keywords = myspace layouts, layouts, myspace code, etc
?>

Of course it'll be much more extensive than that just trying to give you the idea. I am really just covering the basics but at the same time hopefully help you understand how it works. I suggest looking this over too it has different methods than what I've covered:
http://www.w3schools.com/PHP/php_includes.asp

Did this help? If not let me know :)

famazingspacedotcom
July 26th, 2008, 05:58 PM
Thanks hun, I'm going to read over this and try to understand it more. I don't like asking for help, so when I do that means I really don't understand. lol If I cant figure it out, I'm going to pull my hair out, then my bald butt will probably bug you some more :online2long:

pinkylicious
July 26th, 2008, 11:05 PM
make your design in a html file first then convert it to php...

if you don't know how, you can always ask me :P

Smurfwicked
July 26th, 2008, 11:42 PM
make your design in a html file first then convert it to php...

if you don't know how, you can always ask me :P

I think that might be misleading to some people. Just because you're using php files doesn't mean everything in html has to be "echo'd" in the format of php. Only time you have to convert your actual html within a php file is when its in between the opening <? and close ?> tags of php. I can't think of any instances where you'd need to use the echo just making a dynamic php navigation site.