Forum Moderators: coopster

Message Too Old, No Replies

need help building site template

         

melissachan

9:34 am on Nov 7, 2003 (gmt 0)

10+ Year Member



i am well versed with HTML but i have very little knowledge on PHP. however i need help with creating a page for my portfolio where it will be based on one template....its hard for me to explain..kinda like a slideshow... antigirlDOTcom is an example of what i want to create....can someone help me out?

would be much appreciated.....

thanks :)

melissa

[edited by: melissachan at 9:45 am (utc) on Nov. 7, 2003]

melissachan

9:35 am on Nov 7, 2003 (gmt 0)

10+ Year Member



by the way, if anyone offers a solution, prefrebly a step by step guide...i'm a total newbie.... :p

coopster

9:38 am on Nov 7, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, melissachan!

I notice one template system in particular that is mentioned quite often on this board called Smarty [smarty.php.net] that you may want to have a look at.

ergophobe

10:12 pm on Nov 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can do a basic template system by using nothing but the "include" function in PHP (check the manual).

Basically, put your header, footer and navigation stuff in separate files and include them on the page. With creative CSS, you can have it display in any number of ways.

The next step up would be a template file that includes the header, footer, navigation and the content for that particular page. You can do that crudely but easily with URLs like

www.domain.com/template.php?page=page1

Then your template would be

template.php
<?php
include('header.php');
include('navigation.php);
include($_GET['page']."php"); //include the file named in URL with page=page1, minus the extension so you can use whatever you want.
include('footer');
?>

So many possibilities to get fancier and fancier, but that might get you started.

melissachan

8:00 am on Nov 18, 2003 (gmt 0)

10+ Year Member




thanks erbophobe! still a little confused, but a little more clearer about php... sorry i missed your reply, havent checked this forum in awhile.

what is the purpose of?page=page1 in the URL?

ergophobe

5:16 pm on Nov 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




what is the purpose of?page=page1 in the URL?

First, I'm going to make this quite verbose, since as I understand you are a beginner. Apologies for being longwinded if you are a programmer who is merely a beginner at PHP.

This is known as a "get" parameter and it sends the info to the server at the time the url is requested. PHP grabs this info and puts it in the "superglobal" array $_GET, which is predefined in PHP. "Superglobal" means the information is available to you everywhere in your script without any additional action on your part. So in the example I gave


www.domain.com/template.php?page=page1

include($_GET['page']."php");

1. You have the superglobal $_GET. This an array that PHP provides (you said you were a total beginner. Do you know what arrays are yet? If not, consult [php.net ]).

2. The superglobal $_GET array is an associative array with elements named for each GET parameter. In this case there is only one and it is referenced by the name "page". You access its value as $_GET['page'].

3. $_GET['page'] has a value of 'page1'. This is a string [php.net].

4. Then, you take that string and use it to figure out which file to plug into your template. In this case, 'page1' plus whatever extension you have. So if the file is named 'page1.php', you would concatenate the extension onto it like so: $_GET['page'] . "php"

$pagefile = $_GET['page'] . "php";

in this case, this is the same as

$pagefile = "page1.php";

So when you plug your data into your template,

include($_GET['page'] . "php");

includes that file and plugs it into the template.

Tom

ergophobe

5:23 pm on Nov 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



PS

havent checked this forum in awhile.

Shame on you! Don't you know it's the best forum on the web? With regard to the first part, I'm just kidding, of course, but I should say WELCOME, since I see you're new.

With regard to the second part, I believe it to be true, and not just for web stuff, but for everything. It's pretty much the only forum I'll read these days - flame wars and insults not allowed. Everyone welcome. Some folks so smart it makes your head spin. I don't think you'll find such a helpful and polite group anywhere on the web!

Tom

stidj

7:45 pm on Nov 19, 2003 (gmt 0)

10+ Year Member



ergophobe

Sorry I have nothing to add here except that I must agree the people here are extremly smart, polite and professional about things.

Thanks to everyone who has helped me and for making this forum so helpful.

melissachan

1:51 am on Nov 24, 2003 (gmt 0)

10+ Year Member



i think i get it, i have yet to try it though. thanks!