SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 96 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"

We normally use cid when we have
come from a page with a selection of records and id when we have come from a
page with one record.
/**
* Foobar Model
*/
class MyextensionModelFoobar extends JModel
{
/**
* Foobar ID
*
* @var int
*/
var $_id;
/**
* Foobar data
*
* @var object
*/
var $_foobar;
/**
* Constructor, builds object and determines the foobar ID
*
*/
function __construct()
{
parent::__construct();
// get the cid array from the default request hash
$cid = JRequest::getVar('cid', false, 'DEFAULT', 'array');
if($cid)
{
$id = $cid[0];
}
else
{
$id = JRequest::getInt('id', 0);
}
$this->setId($id);
}
Component Design
[ 72 ]
/**
* Resets the foobar ID and data
*
* @param int foobar ID
*/
function setId($id=0)
{
$this->_id = $id;
$this->_foobar = null;
}
/**
* Gets foobar data
*
* @return object
*/
function getFoobar()
{
// if foobar is not already loaded load it now
if (!$this->_foobar)
{
$db =& $this->getDBO();
$query = "SELECT * FROM ".$db-
>nameQuote('#__myextension_foobar')
" WHERE ".


Pages:
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108