Question

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?

Was it helpful?

Solution

Look into the Model-View-Controller Pattern

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top