Joomla get('Items') and how it works Joomla get('Items') and how it works php php

Joomla get('Items') and how it works


I'm presuming 1.7/2.5+ here...

In Joomla!'s MVC the view contacts (ContactViewContacts which extends JView) automatically loads the model contacts (or in J! terminology ContactModelContacts) which as a class extends JModelList.

The get() looks in the view to get data from a registered model or a property of the view.

So;

$this->items = $this->get('Items');

is actually a call to the model ContactModelContacts which has a matching getItems() in it's parent.

The model file com_contact/models/contacts.php doesn't implement it's own getItems(), so the getItems() from the JModelList class is used (found in /libraries/joomla/application/component/modellist.php).

This in turn calls getListQuery() - no magic just inheritance.

The $this->get('Pagination') is doing the same thing, ie. accessing the implementation in the models parent.

The $this->get('State') is probably going all the way back to the JModel implementation.