Forum Moderators: coopster

Message Too Old, No Replies

PHP Template

         

buckmajor

12:18 pm on Jun 9, 2008 (gmt 0)

10+ Year Member



Hi there

I am still learning PHP and have a basic understanding of using the include in PHP.

Would anyone know how to do a template for php and if you can kindly break it down for me as I am still in the beginning stages of PHP.

Many thanks in advance

CHEERS :)

jatar_k

12:19 pm on Jun 9, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



maybe try this thread from our Library [webmasterworld.com]

A dynamic site in 2 minutes [webmasterworld.com]

buckmajor

1:03 pm on Jun 9, 2008 (gmt 0)

10+ Year Member



Thanks Jakar

I read that one line template but didn't understand it well lol. Are you able to help me out with a php template in a simpler form? If not, then just need a bit of more help with the one line template. How do I write it out properly?

CHEERS

Baruch Menachem

2:02 pm on Jun 9, 2008 (gmt 0)

10+ Year Member



Essentially, the concept is to separate content and mark up as much as possible, and to make everything as modular as possible.

One of the true lifesavers of coding is the $includes file. It is also good design. The advice given here is to break things as much as possible so that only the stuff that is part of that page is on that page. All the stuff that spreads across pages is in a separate file that each page can load.

buckmajor

5:13 am on Jun 10, 2008 (gmt 0)

10+ Year Member



Hey guys

I got this going now yippy. Hope I did it right though lol.
Thanks a lot, that one line template works but the only problem I have is adding javascript to the individual page.

Any suggestions?

Many thanks in advance
CHEERS :)

andrewsmd

7:41 pm on Jun 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want to add javascript to the page with php then just add it in the same way you would add html with php. I.E. print("<your javascript opening tag here>javascript code here</script>");

wsamoht

3:08 am on Jun 11, 2008 (gmt 0)

10+ Year Member



I am having trouble with the Dynamic Site in 2 minutes. I am using
<?php
include 'includes/header.php';
?>
Here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<link rel="shortcut icon" href="/images/favicon.ico" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="$$$$$$$$$$$$$$$$$$$" />
<meta name="keywords" content="$$$$$$$$$$$" />
<title>*******************</title>
<link rel="stylesheet" href="styles.css" type="text/css" />
<script type="text/javascript" src="nav.js"></script>
<style type="text/css">
#phases {
list-style-type: none;
margin-left: 0px;
padding-left: 20px;
}
</style>
</head>
<body>
<?php
include 'template.html';
?>
</body>
</html>

Am i doing this right? I saved the file as .php. The problem I am having is that my page is not being formatted with my external style sheet. Everything else seems to be fine, it is reading my external javascript file. Not sure what to do.

wsamoht

3:24 am on Jun 11, 2008 (gmt 0)

10+ Year Member



actually i think i figured it out. For some reason it wasn't working on my computer (having my computer act as the server) but when i uploaded it to my site it is working fine. Thanks anyways! :)

buckmajor

3:58 am on Jun 11, 2008 (gmt 0)

10+ Year Member



Cool! I will try that pint script for Javascript thanks guys.
Awesome, you got it going Wsamoht.

CHEERS :)

Marcia

6:34 am on Jun 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>actually i think i figured it out

I haven't figured out how to separate the scripting from the HTML/CSS without doing individual .html pages, so until I do I've got them together and it works.

The template system I set up has a template.php set up with the entire page HTML/CSS code, with includes for the header (graphic, ets), side navigation and footer, and an include for the page content. I don't have to make any .html pages, using one line in .htaccess - just the one template and file.inc.php text files for the includes - it does it all, and works perfectly.

The only problem is that no other pages with the .html file extension can be in that same folder, because that template and rewrite will over-ride differently done pages in the folder.

I'm not sure which is the better way to do it, but until I figure out how to separate them, this will do.

If you separate the PHP from the html/css you still have to make separate .html pages for each page, right?

[edited by: Marcia at 6:54 am (utc) on June 11, 2008]

buckmajor

3:21 pm on Jun 16, 2008 (gmt 0)

10+ Year Member



Hey Marcia

I'm not sure cause everyone has there their own way of doing it. But there is a 1 page template you can do and build php pages from there which I find it easier to use.