Quick search:

Principle

PhpPeanuts does not include a graphical editor and does not generate any code. It does use scripts inside HTML for the graphical layout and composition, but helps you to keep the HTML very clean.

In order to do that, phpPeanuts follows a variant of the Model View Controller pattern called the 'composition by inclusion and callback patternpages are composed graphically and functionally from parts, which again are composed from smaller parts. The graphical composition in done in skins (views), php files which are included by pages or parts (both controllers). These skins contain HTML and callbacks to the page or part that included them. Some of these callbacks just print data, but others will create a new subdivision by including another part that on its turn may include a skin of its own. In the Collaboration Diagram below you can see which skins a page usually includes and which callbacks are made.

web.principle.gif
Click here to view this diagram in svg.

Because different pages have different parts, and because you can specialize the parts by application or by the pntType, it is not always evident how graphical composition is done and how it corresponds to functional composition. The best way to find out the composition is to set the debug mode field in the class Site to verbose, refresh the page in your browser and then select 'View Source' in the browser. See how to specialize a part of a page.

Understanding graphical composition from the HTML source may be somewhat harder. Therefore we included Graphical Composition Diagrams of each in this documentation.

In order to keep you HTML clean you are strongly advised only to make callbacks to the page or part that included the HTML. If you need more function than the page or part offers, you better subclass it or add a new part class, write the code in functions on the subclass or part class, and then call the newly written functions from the HTML.

Now you may ask: what about the model? The model consists of the peanuts in the domain model that is viewed through the pages and parts.

Of course a pattern can not be bound to a specific framework. Click here for an example of the pattern that does not use any phpPeanuts framework code.