API16

JModel: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> {{Description:JModel}} ===Defined in=== librari...
 
m preparing for archive only
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<span class="editsection" style="font-size:76%;">
[[JModel]] is an abstract class which provides the basic functionality for concrete model objects in conjunction with Joomla's MVC pattern. Models that extend the JModel class are often defined in Joomla components and define the business logic of the specific component. See [[Developing_a_Model-View-Controller_Component_-_Part_1 | MVC Development in Joomla]]
<nowiki>[</nowiki>[[Description:JModel|Edit Descripton]]<nowiki>]</nowiki>
 
</span>
===The Joomla MVC Design Pattern===
{{Description:JModel}}
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.


===Defined in===
===Defined in===
Line 42: Line 46:
|Adds to the stack of model table paths in LIFO order.
|Adds to the stack of model table paths in LIFO order.
|}
|}
===Importing===
===Importing===
<source lang="php">jimport( 'joomla.application.component.model' );</source>
<source lang="php">jimport( 'joomla.application.component.model' );</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JModel|Edit See Also]]<nowiki>]</nowiki>
 
</span>
{{SeeAlso:JModel}}


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=JModel
  category=JModel
  category=CodeExample
  namespace=CodeExample
  category=ClassExample
  category=ClassExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>

Latest revision as of 01:54, 25 March 2017

JModel is an abstract class which provides the basic functionality for concrete model objects in conjunction with Joomla's MVC pattern. Models that extend the JModel class are often defined in Joomla components and define the business logic of the specific component. See MVC Development in Joomla

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.

Defined in

libraries/joomla/application/component/model.php

Methods

Method name Description
__construct Constructor
setState Method to set model state variables
getState Method to get model state variables
getDbo Method to get the database connector object
setDbo Method to set the database connector object
getName Method to get the model name
getTable Method to get a table object, load it if necessary.
getInstance Returns a Model object, always creating it
addIncludePath Add a directory where JModel should search for models. You may either pass a string or an array of directories.
addTablePath Adds to the stack of model table paths in LIFO order.

Importing

jimport( 'joomla.application.component.model' );



Examples

Code Examples