JView/1.6
(Updates for 1.6) |
m (→User contributed notes) |
||
| Line 111: | Line 111: | ||
</span> | </span> | ||
===User contributed notes=== | ===User contributed notes=== | ||
| + | In extensions included in the Joomla! release, display methods typically consist of a collection of calls to the view's related model method, supplemented with additional logic to prepare data for display before calling the parent display() function which in turn takes responsibility for the template display. | ||
| + | The model calls are somewhat standardized depending on the related model class that is used (or derived from). | ||
| + | |||
| + | JModelAdmin (typically back end single object creation/editing) | ||
| + | <source lang="php"> | ||
| + | $this->form = $this->get('Form'); // gets the form definition that will be | ||
| + | $this->item = $this->get('Item'); //when the corresponding model is JModelItem or a subclass | ||
| + | $this->state = $this->get('State'); | ||
| + | </source> | ||
| + | |||
| + | JModelList (typically back end views that display a collection of objects) | ||
| + | <source lang="php"> | ||
| + | $this->items = $this->get('Items'); | ||
| + | $this->pagination = $this->get('Pagination'); | ||
| + | $this->state = $this->get('State'); | ||
| + | </source> | ||
| + | |||
| + | JModelAdmin, JModelList and their descendants usually provide a method called addToolbar() which provides the logic to display the icons and action selections in back end extensions. | ||
| + | |||
| + | JModelItem (typically front end views of object(s) ) | ||
| + | <source lang="php"> | ||
| + | $this->state = $this->get('State'); | ||
| + | $this->item = $this->get('Item') | ||
| + | </source> | ||
| + | |||
<CodeExamplesForm /> | <CodeExamplesForm /> | ||
<dpl> | <dpl> | ||
Latest revision as of 23:12, 2 July 2011
[edit]
JView
[edit] Description
JView is an abstract class which provides the basic functionality for Joomla's MVC design pattern. You need to write your own concrete View classes, to make full use of the functionality. Learn more
[edit] The Joomla MVC Design Pattern
Model-View-Controller (MVC) is a set of design patterns, that are used to separate the different layers of your application.
- The View displays the data of the model by passing it to a template. The view object can therefore access the data of the model. Joomla implements the basic functionality in the abstract JView class.
- The Model stores the data of the application, and contains the business logic. Joomla implements the basic functionality in the abstract JModel class.
- The Controller handles the user requests and evokes the model and the views to change it's state. Joomla implements the basic functionality in the JController class.
[edit] Methods
| Visibility | Method name | Description |
|---|---|---|
| public | __construct | Constructor. |
| public | _addPath | Adds to the search path for templates and resources. |
| public | _createFileName | Create the filename for a resource. |
| public | _setPath | Sets an entire array of search paths for templates or resources. |
| public | addHelperPath | Adds to the stack of helper script paths in LIFO order. |
| public | addTemplatePath | Adds to the stack of view script paths in LIFO order. |
| public | assign | Assigns variables to the view script via differing strategies. |
| public | assignRef | Assign variable for the view (by reference). |
| public | display | Execute and display a template script. |
| public | escape | Escapes a value for output in a view script. |
| public | get | Method to get data from a registered model or a property of the view. |
| public | getLayout | Get the layout. |
| public | getLayoutTemplate | Get the layout template. |
| public | getModel | Method to get the model object. |
| public | getName | Method to get the view name. |
| public | loadHelper | Load a helper file. |
| public | loadTemplate | Load a template file -- first look in the templates folder for an override. |
| public | setEscape | Sets the _escape() callback. |
| public | setLayout | Sets the layout name to use. |
| public | setLayoutExt | Allows a different extension for the layout files to be used. |
| public | setModel | Method to add a model to the view. |
- Defined in libraries/joomla/application/component/view.php
- Extends JObject
[edit] Importing
jimport( 'joomla.application.component.view' );
[edit] See also
-
JView source code on JoomlaCode
-
Subpackage Application
- Other versions of JView
[edit] User contributed notes
In extensions included in the Joomla! release, display methods typically consist of a collection of calls to the view's related model method, supplemented with additional logic to prepare data for display before calling the parent display() function which in turn takes responsibility for the template display. The model calls are somewhat standardized depending on the related model class that is used (or derived from).
JModelAdmin (typically back end single object creation/editing)
$this->form = $this->get('Form'); // gets the form definition that will be $this->item = $this->get('Item'); //when the corresponding model is JModelItem or a subclass $this->state = $this->get('State');
JModelList (typically back end views that display a collection of objects)
$this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State');
JModelAdmin, JModelList and their descendants usually provide a method called addToolbar() which provides the logic to display the icons and action selections in back end extensions.
JModelItem (typically front end views of object(s) )
$this->state = $this->get('State'); $this->item = $this->get('Item')
<CodeExamplesForm />