API16

JView/get

From Joomla! Documentation

< API16:JView
Revision as of 17:36, 22 March 2010 by Doxiki (talk | contribs) (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...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The "API16" 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.

Description[edit]

Method to get data from a registered model or a property of the view

[Edit Descripton]

Template:Description:JView/get

Syntax[edit]

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[edit]

mixed The return value of the method

Defined in[edit]

libraries/joomla/application/component/view.php

Importing[edit]

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

Source Body[edit]

public 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;

}

[Edit See Also] Template:SeeAlso:JView/get

Examples[edit]

<CodeExamplesForm />