View and AbstractView classes

One of the most vital part of PHP framework is quick performance. As an object-oriented programmer you must make proper choices when selecting parent of your newly added classes. When you are going to create your own Views you will always have a choice to inherit from either "View" or "AbstractView" class.


This class should be used when in doubt for maximum performance. AbstractView can be only used if it's extended. This class introduces basic rendering concepts and use of template, but it makes no assumptions about your template.

AbstractView does not have a default template, so you must always define template for it by overriding defaultTemplate()


With View you does not necessarily have to extend it when using. View has a default template which will output a <div> element.

View adds several useful methods which can easily change the output without providing a new template:

(Prior to 4.2, View class was referred to as HtmlElement).

Standard classes based on View

Some classes are based on View and simply configure it in the proper way such as H1, H2, H3, H4, H5, P, HR. If you want to have more classes as such, define them locally in the consistent way.

IMPORTANT: Excessive use (thousands of) of View object may affect your application performance.

Special template tags

View and AbstractView will replace tag <?$_name?> with the name of current object. They will also look for all occurrences of "template" tag and pass content of those tags through "locateURL" method of pathfinder.

Choice of controllers

When you call $view->setModel($m) on a very basic view, then it will simply set $view->model accordingly. More complex views, however, will want to perform certain action with a model. To separate out binding functionality within standard models, agile toolkit is using Controllers.

Class Grid_Basic defines $default_controller property to 'Controller_MVCGrid' which then is responsible for populating columns from the model.

Models typically have no View-related logic. If you, however, associate some view logic with the controller, such as special hint next to one of the form fields or conditional display behaviour, you can define $model->default_controller which will be initialized by setModel().