Page 1 of 1

php classes programming

Posted: Thu Jul 27, 2006 3:08 am
by student1980
Hi,

I have a 10 page wizard. Each page has the identical simple layout consisting of : 1) title of the page 2) a body text of 5 lines 3) 4 buttons at the bottom.

I need the following. I want to have 1 file with a class created in php. Each time you call the methods of the class the title of the page is automatically made, the buttons are created.

I have the following the questions:

1) how to make this class

2) in this class I also define the size, color , location of the buttons and title and body text within the method , is this correct or shall I create a style sheet CSS and link it into the class.

3) when i finsihed the class file i want to have 10 separate php files , 1 for each page and include the class the file everytime in the page file. Is this a correct or easy way to this?

Please help me i am a php newbie. I have MSN as well.. Please let me know how I can ask you foryour advice.

Many thanks

Posted: Thu Jul 27, 2006 3:32 am
by Chris Corbyn
10 pages, that's more than one class ;) It's at least 10.

It sounds like what you're looking to create is a template or View Component. We clearly can't answer each of those questions or we'd finish up writing the class for you. It may turn out you need more than one class per page.

As for the syling issues, you shouldn't have you classes dealing with markup in this way. Use CSS for that.

You'd end up basically with a class, which you can load a template into, then the template can do things like:

Code: Select all

<head>
    <title><?php echo $this->title(); ?></title>
</head>
Look at http://uk.php.net/manual/en/ sections 18 and 19.

Posted: Thu Jul 27, 2006 3:37 am
by student1980
thanks do you have msn? so i can chatwith you?

why do i need 10 classes?:)

i have 10 almost identical pages.. so just write 1 class file and include that single class file in all those 10 pages , for every page i have a file so page1.php, page2.php ... page10.php

Posted: Thu Jul 27, 2006 3:40 am
by Chris Corbyn
student1980 wrote:thanks do you have msn? so i can chatwith you?

why do i need 10 classes?:)

i have 10 almost identical pages.. so just write 1 class file and include that single class file in all those 10 pages , for every page i have a file so page1.php, page2.php ... page10.php
Ah OK I guess if the page or some similar it's probably fine to use the same class.

I have MSN but I'm working at the moment, and what's the point of a web forum if people don't use it for discussion? :? Sorry to come across bluntly, but that's why we have a forum :)

Posted: Thu Jul 27, 2006 3:48 am
by student1980
ok ;)

so actually there are several steps, can you tell me whether this is correct.

1) create a page object with class with methods such as create_button1(), create_button2() .... create_button4(), create_title(), create_header()

2) create a css style sheet which defines the size of the page, the size and location of the buttons, the size&color&font display of the header and title and include this in the class file

3)create 10 pages called page1.php , page 2. php .... page10.php and include the class file (within this class file the css style sheet is included) in each php file

4)change the content yourself , all the other stuff of the user interface is being sput out by php


It is for a simple wizard.

Is this correct ?