JView/get: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Method to get data from a registered model or a property of the view
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JView/get|Edit... |
m preparing for archive only |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 3: | Line 3: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[< | <nowiki>[<! removed edit link to red link >]</nowiki> | ||
</span> | </span> | ||
<! removed transcluded page call, red link never existed > | |||
===Syntax=== | ===Syntax=== | ||
<source lang="php">get($property, $default=null)</source> | <source lang="php">& get($property, $default=null)</source> | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 36: | Line 36: | ||
===Source Body=== | ===Source Body=== | ||
<source lang="php"> | <source lang="php"> | ||
function &get( $property, $default = null ) | |||
{ | { | ||
| Line 43: | Line 43: | ||
$model = $this->_defaultModel; | $model = $this->_defaultModel; | ||
} else { | } else { | ||
$model = strtolower($default); | $model = strtolower( $default ); | ||
} | } | ||
// First check to make sure the model requested exists | // First check to make sure the model requested exists | ||
if (isset($this->_models[$model])) | if (isset( $this->_models[$model] )) | ||
{ | { | ||
// Model exists, lets build the method name | // Model exists, lets build the method name | ||
| Line 63: | Line 63: | ||
// degrade to JObject::get | // degrade to JObject::get | ||
$result = parent::get($property, $default); | $result = parent::get( $property, $default ); | ||
return $result; | return $result; | ||
| Line 70: | Line 70: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[< | <nowiki>[<! removed edit link to red link >]</nowiki> | ||
</span> | </span> | ||
<! removed transcluded page call, red link never existed > | |||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=get | category=get | ||
category=JView | category=JView | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
[[Category:Archived pages API15]] | |||
Latest revision as of 01:16, 25 March 2017
Description
Method to get data from a registered model or a property of the view
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax
& get($property, $default=null)
| Parameter Name | Default Value | Description |
|---|---|---|
| $property | The name of the method to call on the model, or the property to get | |
| $default | null | The name of the model to reference, or the default value [optional] |
Returns
mixed The return value of the method
Defined in
libraries/joomla/application/component/view.php
Importing
jimport( 'joomla.application.component.view' );
Source Body
function &get( $property, $default = null )
{
// If $model is null we use the default model
if (is_null($default)) {
$model = $this->_defaultModel;
} else {
$model = strtolower( $default );
}
// First check to make sure the model requested exists
if (isset( $this->_models[$model] ))
{
// Model exists, lets build the method name
$method = 'get'.ucfirst($property);
// Does the method exist?
if (method_exists($this->_models[$model], $method))
{
// The method exists, lets call it and return what we get
$result = $this->_models[$model]->$method();
return $result;
}
}
// degrade to JObject::get
$result = parent::get( $property, $default );
return $result;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
Code Examples