views:

76

answers:

3

I am trying to build the interface of my WEB site using OOP. For this I need to have several objects like menu, thumbnails, contentBoxes joined together to form a complete layout.

I know OOP is not used for presentation but I need to do it anyway. Can anyone help me on this?

+2  A: 

Look into the Model-View-Controller Pattern

GSto
can't interface be accomplished in n-tier
Starx
A: 

I believe that doing this in PHP is like trying to invent a bicycle while you are only allowed to use rectangular objects. If you want OOP-based web design - ASP.NET is the way to go.

Ghostrider
-4 so far... yeah... and now everyone would start telling me that PHP is a proper language for OO UI design... yeah, right
Ghostrider
I think it's more that you're suggesting ASP.NET instead ;)
Stephen Orr
If you think PHP can't do OOP-based web design, you're not doing it right.
Lotus Notes
A: 

You can start with something really simple like all object inherit from this interface or abstract class where you have a method called render() that spits all the html out. The building of the html is ditacted by the value of your properties, say a menu as a collection of link objects, in render you build all the html for those links.

Going one step furter you can start modeling the properties of your objects say divs have child elements, so you can allow certain objects (inherit from the Interface IBlockElement) to have other objects as childs (Interface IInlineElement).

You can the implementn implement it in a way that when the parent object renders all child elements render methos is also called. Say you do $page->render() and all the inner elements would render, spitting all your html.

This is mainly from my experience developing in .NET Hope this makes sense

Luis