Working in Joomla, I have my model and view set up, but when the page is loaded, no data appears.
Model:
class mlsModelmls extends JModel
{
/**
* Gets the info
*/
function mlsdata($column)
{
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM ".$db->nameQuote('#__mls')."
WHERE ".$db->nameQuote('MSTMLSNO')." = ".$db->quote('4112065').";
";
$db->setQuery($query);
$row = $db->loadRow();
print_r($row[$column]);
}
}
View:
class mlsViewmls extends JView
{
function mlsnum($tpl = null)
{
$model = &$this->getModel();
$mlsnum = $model->mlsdata(MSTMLSNO);
$this->assignRef( 'mlsnum', $mlsnum );
$agentuid = $model->mlsdata(MSTLISTBRD);
$this->assignRef( 'agentuid', $agentuid );
$listdt = $model->mlsdata(MSTLISTDT);
$this->assignRef( 'listdt', $listdt );
/** Some more assignRef() */
parent::display($tpl);
}
}
TMPL:
<h2 class="price">
<?php echo $this->mlsnum; ?>
</h2>
When the page is loaded, the TMPL looks fine, but no data appears for the <?php echo $this->mlsnum; ?>
reference call.
Does each assignRef()
need it's own function?
Try to change
print_r($row[$column]);
to this:
return $row[$column];
And this one
parent::display($tpl);
to
return parent::display($tpl);
Otherwise it's just no-result.
Your mlsdata()
method doesn't returning anything, therefore you are assigning nothing to the template variable.
Add return $row
and remove the print_r
.
Try changing your model function to this:
function mlsdata($column) {
$db =& JFactory::getDBO();
$query = " SELECT * FROM ".$db->nameQuote('#__mls')." WHERE ".$db->nameQuote('MSTMLSNO')." = ".$db->quote('4112065').";
$db->setQuery($query);
$row = $db->loadRow();
return $row;
}