Difference between revisions of "JView"
From Joomla! Documentation
m (→User contributed notes: bad link repair) |
m (preparing for archive only) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
=={{JVer|11.1}} JView== | =={{JVer|11.1}} JView== | ||
===Description=== | ===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. [[Developing_a_Model-View-Controller_Component_-_Part_1|Learn more]] | |
− | + | ||
− | + | ===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. | ||
+ | |||
===Methods=== | ===Methods=== | ||
{| class="wikitable sortable" | {| class="wikitable sortable" | ||
Line 14: | Line 19: | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::addHelperPath | + | |[[API17:JView::addHelperPath|addHelperPath]] |
|Adds to the stack of helper script paths in LIFO order. | |Adds to the stack of helper script paths in LIFO order. | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::addTemplatePath | + | |[[API17:JView::addTemplatePath|addTemplatePath]] |
|Adds to the stack of view script paths in LIFO order. | |Adds to the stack of view script paths in LIFO order. | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::assign | + | |[[API17:JView::assign|assign]] |
|Assigns variables to the view script via differing strategies. | |Assigns variables to the view script via differing strategies. | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::assignRef | + | |[[API17:JView::assignRef|assignRef]] |
|Assign variable for the view (by reference). | |Assign variable for the view (by reference). | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::display | + | |[[API17:JView::display|display]] |
|Execute and display a template script. | |Execute and display a template script. | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::escape | + | |[[API17:JView::escape|escape]] |
|Escapes a value for output in a view script. | |Escapes a value for output in a view script. | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::get | + | |[[API17:JView::get|get]] |
|Method to get data from a registered model or a property of the view. | |Method to get data from a registered model or a property of the view. | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::getLayout | + | |[[API17:JView::getLayout|getLayout]] |
|Get the layout. | |Get the layout. | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::getLayoutTemplate | + | |[[API17:JView::getLayoutTemplate|getLayoutTemplate]] |
|Get the layout template. | |Get the layout template. | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::getModel | + | |[[API17:JView::getModel|getModel]] |
|Method to get the model object. | |Method to get the model object. | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::getName | + | |[[API17:JView::getName|getName]] |
|Method to get the view name. | |Method to get the view name. | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::loadHelper | + | |[[API17:JView::loadHelper|loadHelper]] |
|Load a helper file. | |Load a helper file. | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::loadTemplate | + | |[[API17:JView::loadTemplate|loadTemplate]] |
|Load a template file -- first look in the templates folder for an override. | |Load a template file -- first look in the templates folder for an override. | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::setEscape | + | |[[API17:JView::setEscape|setEscape]] |
|Sets the _escape() callback. | |Sets the _escape() callback. | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::setLayout | + | |[[API17:JView::setLayout|setLayout]] |
|Sets the layout name to use. | |Sets the layout name to use. | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::setLayoutExt | + | |[[API17:JView::setLayoutExt|setLayoutExt]] |
|Allows a different extension for the layout files to be used. | |Allows a different extension for the layout files to be used. | ||
|- | |- | ||
|public | |public | ||
− | |[[JView::setModel | + | |[[API17:JView::setModel|setModel]] |
|Method to add a model to the view. | |Method to add a model to the view. | ||
|- | |- | ||
|protected | |protected | ||
− | |[[JView::__construct | + | |[[API17:JView::__construct|__construct]] |
|Constructor. | |Constructor. | ||
|- | |- | ||
|protected | |protected | ||
− | |[[JView::_addPath | + | |[[API17:JView::_addPath|_addPath]] |
|Adds to the search path for templates and resources. | |Adds to the search path for templates and resources. | ||
|- | |- | ||
|protected | |protected | ||
− | |[[JView::_setPath | + | |[[API17:JView::_setPath|_setPath]] |
|Sets an entire array of search paths for templates or resources. | |Sets an entire array of search paths for templates or resources. | ||
|- | |- | ||
|} | |} | ||
* '''Defined in''' libraries/joomla/application/component/view.php | * '''Defined in''' libraries/joomla/application/component/view.php | ||
− | * '''Extends''' [[JObject | + | * '''Extends''' [[API17:JObject|JObject]] |
===Importing=== | ===Importing=== | ||
<source lang="php">jimport( 'joomla.application.component.view' );</source> | <source lang="php">jimport( 'joomla.application.component.view' );</source> | ||
===See also=== | ===See also=== | ||
* {{JVer|11.1}} '''JView source code''' on [[jplatform:application/component/view.php|BitBucket]] | * {{JVer|11.1}} '''JView source code''' on [[jplatform:application/component/view.php|BitBucket]] | ||
− | * {{JVer|11.1}} Subpackage [[Subpackage Application | + | * {{JVer|11.1}} Subpackage [[API17:Subpackage Application|Application]] |
− | * [[JView|Other versions of JView]] | + | * [[API17:JView|Other versions of JView]] |
− | + | ||
− | + | ||
− | |||
− | |||
===User contributed notes=== | ===User contributed notes=== | ||
− | + | === Code Examples === | |
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=JView | category=JView | ||
− | + | namespace=CodeExample | |
category=ClassExample | category=ClassExample | ||
include=* | include=* | ||
Line 117: | Line 120: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
− | <noinclude> | + | <noinclude>[[Category:Platform 11.1]][[Category:Archived pages API17]]</noinclude> |
Latest revision as of 22:56, 24 March 2017
The "API17" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
JView[edit]
Description[edit]
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
The Joomla MVC Design Pattern[edit]
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.
Methods[edit]
Visibility | Method name | Description |
---|---|---|
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. |
protected | __construct | Constructor. |
protected | _addPath | Adds to the search path for templates and resources. |
protected | _setPath | Sets an entire array of search paths for templates or resources. |
- Defined in libraries/joomla/application/component/view.php
- Extends JObject
Importing[edit]
jimport( 'joomla.application.component.view' );
See also[edit]
- JView source code on BitBucket
- Subpackage Application
- Other versions of JView
User contributed notes[edit]
Code Examples[edit]