Jump to content
xisto Community
Sign in to follow this  
KansukeKojima

Nice Clean Php Layout Coding. Learn a nice neat way to code your layouts with php

Recommended Posts

There are basically two main ways to code your php.Method 1) Creating a php document with an html look. The you throw in include tags all over the place. Its unorganized, and you have lots of stray files hidden in folders and scattered in your base directory. Its difficult to organize, and you make mistakes easily.Example:

This document would be called index.php<html><title>Whatever</title><body><table width=750><td>Banner or something</td><tr><td width=500>Some content here. Mostly along the lines of <?php include "whatever content page"; ?></td><td width=250><?php include "whatever navigation page"; ?></td></tr></body></html>

You might ask what the problem was? Well, those include tags tend to multiply, and so do all those unnecesary content pages all over your sever. It gets quite messy and you can make some bad errors when that happens. Method 2) In order to avoid this we can make up for many of those extra pages by including much of the content in the same php tag!

<?php//----------------------//content is going here//---------------------------$content[1] = <<< htmlWHATEVER CONTENT GOES HEREhtml;$content[2] = <<< htmlMORE CONTENT GOES HEREhtml;$banner = <<< html<img src="whateverpath">html;$footer = <<< html<img src="whatever path"><br>copyright blablablahtml;//--------------------------//layout is below//-------------------------$layout = <<< html<table width=750><td width=750>$banner</td><tr><td width=500>$content[1]</td><td width=250>$content[2]</td></tr><tr><td width=750>$footer</td></tr>html;echo "$layout";?>

Understand? Its very neat, very manageable, and very versatile. Another great advantage to this is that if you have a bunch of buttons for affiliates/whatever, you can easily include them wherever just by placing the button variables wherever you want them. As you get better at php and this technique, you may eventually be able to have all you pages on one file... it may be a little adventure when you code but its possible if you put all of you different pages as variables and just link to those variables... Well I hope you enjoyed this and I hoped it helped. :rolleyes:

Share this post


Link to post
Share on other sites

here is a few php editors you my be interested in:

PHP Rite 1.47

PHP Rite is a professional php editor that provides advanced features like word select, code block indentation, syntax highlighting, line numbers, and go to line number. In addition, this php website editor has built-in php syntax reorganization functions. You will be able to edit php files and other ASCII files, such as Rich Text files, HTML files, and TXT files. PHP Rite is a small but robust website editor. It has a convenient toolbar with the most commonly used commands. With sequential line numbers, you'll be able to easily identify where you need to add or modify code. You'll also have the ability to indent a selected block of code and have the ability to create a new instance with a single mouse click. Not only does it have all the standard features of any php website editor, the colorize function and automatic syntax highlighting is what makes this software a must have for any webmaster who writes code! # Easy to access toolbar and menu # Open and Save php, HTML, Rich Text, TXT files # Ability to create new instance with a mouse click # Print php, HTML, Rich Text, or TXT files # List of recently used files # Unlimited UNDO and Redo. # Cut, copy, paste functions # Ability to indent a selected block of code # Insert Date/Time in 4 different formats # Select a word feature # Ability to go to any line number # Find and replace functions # Colorize function # Automatic syntax highlighting # Change font size # Custom TAB size # Word wrap
15 day free trial version
http://www.phprite.com/


DzSoft PHP Editor ver.4.1.0.9

DzSoft PHP Editor is a handy and powerful tool for writing and testing PHP and HTML pages. With its deceptive simplicity, the interface of DzSoft PHP Editor is comfortable both for beginners and experienced programmers, making PHP development easy and productive. Key Features: * PHP and HTML/XML Syntax Highlighting * Built-in FTP Client * The Code Explorer * The File Explorer * Project Manager * NEW: File Search Utility * One-click run and preview * Syntax Checking * Full reporting of errors and warnings * Full control of the input data and environment variables * Support for virtually all currently used Content-Types. That means that you can run scripts which generate any content (for example, images) * PHP extensions supported * Quick insertion of PHP functions * Features for quick navigation in the code * Customizable Code Templates * Possibility to export the source code to HTML and print it with syntax highlighting * Bookmarks * Tabbed multi-document interface * PHP Help support with quick keyword search * Different keymapping schemes (Default, Classic, Brief, Epsilon, Visual Studio) * Windows/Unix/Mac file formats support

http://www.dzsoft.com/ (other code editors as well)

i am sure there are freeware programs as well, just google free php editor
Notice from jlhaslip:
quote tags added

Share this post


Link to post
Share on other sites

In my first post I said that you could have all your pages on one file. Well, I'll show you how to do it now, so you don't have to figure it out.


This file would be called index.php<?php$pageone = <<< htmlblabla bla this is page one!!!html;$pagetwo= <<< htmlblabla bla this is page two!!!html;$default = "$pageone"; if ($_GET['id'] == ""){	$id = $default;}elseif (isset($_GET['id'])){	$id = $_GET['id'];}$template = <<< html<html><title>Whatevs</html<body><table width=780><td width=780>$id<br><br><a href="index.php?id=$pageone">Go to page one!</a><br><a href="index.php?id=$pagetwo">Go to page two!</a></td></table></body></html>html;echo $template;?>
All your doing is creating variables to act as pages. You change the variable when you click a link, so the new variable will be displayed in place of the old one. I'm currently using this for my blog.

Also, I recomend using this only for small scale websites, or minisites, etc. If there is one error it blows up the whole page, so the more code you have the harder it is to fix :)

Understand? It took me for ever... so don't be surprised if you can't figure it out for a little while...

Share this post


Link to post
Share on other sites

Theres something I'm having trouble with though.. I can't have any links or anything in the variables which really sucks... no php code either, it has to be straight text... formatting tags work... is there anyway to make it so I can have links and stuff in the content variables?

Share this post


Link to post
Share on other sites

You could also always use the $_GET variables. With $_GET you can create a whole website within a single file.

EDIT: Providing Example

How you would use the If statements is like this.

<?phpif ($_GET['page'] == 'put_name_here'){?><!-- HTML Code --><?php}elseif ($_GET['page'] == 'another_page'){?><!-- HTML Here --><?php}else{?><!-- Main Page Here --><?php}?>

This is how you would do links.
<a href="page.php?page=page">Name</a>

To include do this
<?phpinclude("page.php?page=page");?>

Edited by coolcat50 (see edit history)

Share this post


Link to post
Share on other sites

So, could I use PHP to script a website skin, or would I have to learn HTML coding? It's all a bit confusing at the moment, heheh. I tried to learn scripting for IRC once, but that didn't work out too well. :) So, anyone care to share a link, or something else on... basic php? Or anything like that.Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.