Nov 8, 2009

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

free web hosting
Open Discussion > MODERATED AREA > Tutorials

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

KansukeKojima
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:

CODE

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!

CODE

<?php
//----------------------
//content is going here
//---------------------------
$content[1] = <<< html
WHATEVER CONTENT GOES HERE
html;

$content[2] = <<< html
MORE CONTENT GOES HERE
html;

$banner = <<< html
<img src="whateverpath">
html;

$footer = <<< html
<img src="whatever path"><br>
copyright blablabla
html;

//--------------------------
//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. smile.gif

 

 

 


Comment/Reply (w/o sign-up)

Poyzin
Wow! This is really cool. I am so using this on my website happy.gif. I gotta learn PHP lol....

Comment/Reply (w/o sign-up)

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

PHP Rite 1.47
QUOTE
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
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

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

 

 

 


Comment/Reply (w/o sign-up)

KansukeKojima
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.


CODE
This file would be called index.php

<?php
$pageone = <<< html
blabla bla this is page one!!!
html;

$pagetwo= <<< html
blabla 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 tongue.gif

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

Comment/Reply (w/o sign-up)

Liam_CF
Php is really great and just the includes alone have cut down the amount of code I have to write myself by about half.

Thank lord for PHP! tongue.gif

Comment/Reply (w/o sign-up)

KansukeKojima
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?

Comment/Reply (w/o sign-up)

coolcat50
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.
CODE
<?php
if ($_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.
CODE
<a href="page.php?page=page">Name</a>


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

Comment/Reply (w/o sign-up)

Relyks
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. laugh.gif
So, anyone care to share a link, or something else on... basic php? Or anything like that.
Thanks!

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : nice, clean, php, layout, coding, learn, nice, neat, code, layouts, php

  1. Create Dynamic Html/php Pages Using Simple Vb.net Code
    Taking your application data, and creating a webpage for others to vie (1)
  2. Add Flashing Inbox To Invisionfree Forum
    Html code for invsiionfree!! (2)
    Do you find it annoying when you are on your invisionfree forum, and you get a new message, and it
    ends up taking you 5 minutes to notice? This code makes the inbox link flash bold red saying how
    many messages you have. In version 1 the word inbox stays the same, and doesnt change at all (for
    Example this is flashing: Inbox (2) In version 2 (the second code) the word inbox changes to
    messages (constantly, so that if you have none, it says messages (0) instead of inbox (0). It still
    flashes Red Put the following In the Header and Body Section (Admin Cp>>>Skinning ....
  3. Web Page Layouts
    using Cascading Style Sheets (7)
    Here are a set of three Web pages I wrote a long time back when I was first starting to develop
    sites. The first one is a two columned page with a full length sidebar for navigation links. There
    are two that are identical except the sidebar positions are reversed. Another is "one way" to create
    a three column layout. And lastly, a 'framed' look on a page. These are not
    'fancy', you will need to look into the code and colourize it to suit, maybe set a width and
    centre it if you want, whatever... Please feel free to snag the source and develop the pages....
  4. [php] Clean Code Functions
    Clean up your html output from php scripts (5)
    There is another Topic about writing 'clean' HTML code posted elsewhere on the Forum.
    I'll edit this Topic and add the link so you can review it on your own, and there is no need for
    me to comment on it in this thread, but the purpose of this Topic is to introduce a pair of
    functions which can be used for making sure that the HTML output from my scripts is readable when a
    view-source is reviewed. Two handy functions are included here. They work together quite nicely,
    and I will start this Tutorial with a short summary of the reasons for their 'being....
  5. Php Random Titles
    Learn to create neat-o random titles! (11)
    PHP Random Titles Description Ever wondered how some websites (ex:spoono.com) have those cool-o
    random titles appearing in the title bar? Now you get to learn how to do it using PHP. We will be
    using our knowledge of Variables and Echos in this tutorial. Try It Out Creating the code itself
    is fairly easy. To start, lets create some of our different titles. Code CODE $title =
    "This will be more fun that that time - never mind..."; $title = "Another random title... neat
    eh?"; $title = "I've got wood... in my fire place..."; $title = "More ranom titl....
  6. Do You Want To Use Php Code In Your Html Pages?
    Within two minutes you will! (9)
    Whilst searching around for help to setup cutenews blog I came across a way to use php in html pages
    - lo and behold it works! so I thought I'd share it with you all (Unfortunately I can't
    remember the site so I wrote this up a couple of minutes after I did it:) ). This method requires a
    web server with apache installed. So, luckily for us all this covers the whole of Trap17... even
    Qupis /tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> Just
    to make the point, this is in no way a difficult task and it doesn't require yo....
  7. Image Gallery Tutorial Using Hoverbox
    A php solution to coding the Hoverbox Image Gallery (15)
    As reported in another posting , there is an Image Gallery named Hoverbox from the Sonspring site
    which is a pretty cool display method using CSS to have Thumbnail pictures double their size by
    hovering over them. I liked the css included in the original Tutorial as found on the Sonspring
    site , but I knew there was more than one use for the Hoverbox and took it upon myself to explore
    the use of the Hoverbox on a site I webmaster. One thing that wasn't right was having to
    hardcode the image tags, so the first version I wrote used php to fill the Hoverbox by rea....
  8. Your First Autoit
    Learning To Code.. (7)
    Autoit is a simple, yet powerful programming language, it allowed the creation of the pangea
    desktops, and the Remote Pc Control with a cell.. You can learn it too. Here is the first of several
    lessons i will post inside of this topic. It is a 32 bit program, it doesnt work on windows 98, 95,
    and i dont think (THINK) Windows ME Step 1: Download and install the latest version of autoit from
    http://www.autoitscript.com i prefer that you use beta. Step 2: Right click somewhere on your
    desktop or my documents, and mouseover new and click Autoit V3 Script Step 3 (optiona....
  9. How To Make Bubble Shaped Layouts
    (8)
    1. Open your layout and make a new document, the same size of your layout. If you don't know
    what size it is, click your layout and go to Image >> Canvas Size. It should show you the Dimensions
    like this: 2. Where it says Current width and height make your new document the same pixels it
    says. Then cancel the Canvas Size. After that, click the Brushes tool and go to your color palette
    and choose Pattern. Say this was my layout: 3. Double click the pattern icon in the color
    palette. Find your layout and click on it. After that find the Tool Options and s....
  10. Php Spy Code
    Spy on your site! (21)
    Code Spy Code Description Anyone who comes to ur forum's IP Adress, Site they came From,
    Their Browser and the time they came will get saved in a place that only the admin knows the
    location of... V.2 More features coming up in V.2!!! POst suggestions/problems... Preview:-
    http://s15.invisionfree.com/Spy/index.php ? REFRESH THE PAGE, AND GO HERE:-
    http://h1.ripway.com/programming/spy%20code/spy.html ^^^^^^^That shows all the IP's, Browsers,
    Time, site and stuff....^^^^^^^^ Code First of all, you'll need to host the files.... I
    suggest you make....
  11. Css Based Photo Gallery Code
    Fluid design for layout (3)
    Fluid Design Photo Gallery There are quite a few Topics here on the Trap17 Forum about how to
    set-up and use Photo Galleries and about the link code for getting from a Thumbnail Image to a full
    size Image and all that stuff, so I would like to take this "Photo Gallery" concept one step further
    without covering what others have already supplied instruction for. Usually, when there is a
    solution posted here for the code on "how-to-do-this", there are tables involved and the Links are
    placed inside Table cells. Tables are not neccesarilly a bad thing, but they were n....
  12. Handy Javascript Code Snips
    Ready to Apply in your webpage (5)
    /tongue.gif' border='0' style='vertical-align:middle' alt='tongue.gif' /> Some common things to
    implement in our webpage very frequently are as follows. How to implement all these I am going to
    tell you in this tutorial. Add To Favorite Set As Homepage Go To Top Of Page No Right Click
    Print Page Adding Current Date Adding Current Time Pop-Up Page Creation Closing Window
    Copyright Notice Updation 01. Add To Favorite Someone may be interested in the content of your
    page. Offer him/her to add the page in his/her favorite menu. To do this you have ....
  13. A Nice Mysql Server Check
    (4)
    I made this and its not very hard at all just fill in the info and it willl see if your mysql is up
    or down CODE Mysql Connection Test // On this you need to put your host most of
    the times localhost username and password. $conncect = mysql_connect ( "host", "Username",
    "password" ) or die (" Sorry your server can't connect to your mysql server Check to see you
    have put in the Username and password and if this is the 1st time you have got this And it has
    worked before That means you need to contact your hoster and tell them my MySql server is....
  14. Css And Javascript Combined For Dynamic Layout
    use of different CSS files at same site (9)
    This tutorial is meant for people that are dealing with problems while coding their site at 100% of
    width. Important notice: Some people has JavaScript disabled, so they will not be able to load CSS
    file (take this in account when creating your website). How this script works. In the HEAD of your
    HTML document will apply this command, so variable.js file will be load at start: CODE
    In browser JavaScript file variable.js is loaded. This Javascript file consist of this parameters,
    copy this code and name it variable.js CODE // JavaScript Document if (sc....
  15. Transparent Scrollbars
    Coding Transparent Scrollbars (2)
    Why woud someone want a Transparent scrollbars you ask? Well fist of they do not cover too much of
    the image like the normal scrollbars. You can use transparent scrollbars for different kinds of web
    layouts such as popups, iframes, or scrolling div layers. For iframes, make sure you've inserted
    a background image for the table cell containing the iframe. You do not need to do that for
    scrolling div layers. Although, you cannot make the main scrollbar transparent unless you make it
    appear that way by selecting the same color for everything. After you code the scroll....
  16. Php Installed Modules Dynamic Reference Tool
    An effective tool for coding in PHP (4)
    PHP Installed Modules Dynamic Reference Tool A dynamic tool for referencing PHP modules and
    their associated routines, which are installed on your web-server. **Note: Uses only 2 functions
    built-in to PHPs core and should be easy to convert to a later version of PHP. This current version
    uses PHP4. Example: PHP Installed Modules Dynamic Reference Tool Abstract : As a PHP
    Developer, it is nice to know what functionality is available to you, and what you would have to
    implement yourself. Some of this functionality is provided for you by the PHP core,....
  17. 'make' A Virus To Test Your Norton Antivirus
    Not a harmful code (0)
    This code is to simply check if your Norton Antivirus is working probably. Not sure if it will work
    on other AVs. The following code is provided by EICAR. QUOTE
    X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!SH+H* Copy the content from the
    code into Notepad and save it as 'eicar.com' If your Norton AV is working probably a pop up
    of a Virus Alert should pop up and removed the virus immidiately. ....
  18. How To Put A Phpbb Login Box On Your Main Site.
    Code and .php included!!! (19)
    I have included my coded file with this... Ok here is the code. CODE // //Create login area,
    replace the phpBB2 in /phpBB2/login.php with your forum's //directory //   Prank Place
    Forum Index     Please enter your username and password to log in.        
                  Username:                   Password:      
                Log me on automatically each visit:                    
    I forgot my password         You can test this out on my....
  19. Simple Layouts
    (14)
    New to HTML? try this simple website layout to get you started. Well, start your site by creating a
    table to display your content. HTML html > head > title > My Webpage /title > STYLE
    type=text/css > @import url( yourname.css ); --> /STYLE > /head > body > table width =" 700 "
    border=" 1 " cellpadding=" 3 " cellspacing=" 0 " align=" center " class=" MAIN_TABLE "> tr > td
    valign =" top " height=" 100 " colspan=" 2 " class=" CELL "> Your banner /td > /tr > tr >
    td width =" 15% " valign=" top " height=" 25 " class=" CELL "> Menu /td >....

    1. Looking for nice, clean, php, layout, coding, learn, nice, neat, code, layouts, php

Searching Video's for nice, clean, php, layout, coding, learn, nice, neat, code, layouts, php
See Also,
advertisement


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

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com