following is the code i am trying to understand of joomla MVC compenet development
protected function getOptions()
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('id,greeting');
$query->from('#__helloworld');
$db->setQuery((string)$query);
$messages = $db->loadObjectList();
$options = array();
if ($messages)
{
foreach($messages as $message)
{
$options[] = JHtml::_('select.option', $message->id, $message->greeting);
}
}
$options = array_merge(parent::getOptions(), $options);
return $options;
}
i am unable to understand following statement
JHtml::_('select.option', $message->id, $message->greeting);
and what is the basic purpose of JHTML class of joomla
JHTML is indeed a class of Joomla, used to print various HTML, like inputs, images, links etc. Here is the documentation:
http://api.joomla.org/Joomla-Platform/HTML/JHtml.html
UPDATE: more recent documentation http://api.joomla.org/cms-3/classes/JHtml.html
The underscore ( _ ) function calls other sub-classes, like
http://api.joomla.org/Joomla-Platform/HTML/JHtmlSelect.html
UPDATE: more recent documentation http://api.joomla.org/cms-3/classes/JHtmlSelect.html
UPDATE: method "_
" documentation http://api.joomla.org/cms-3/classes/JHtml.html#method__
and the part after the dot ( . ) is the function called. In this case:
http://api.joomla.org/Joomla-Platform/HTML/JHtmlSelect.html#option
i was reading a book about Joomla called JOOMLA PROGRAMMING, so i discovered what's the function of the method _(underscore) from class JHml, he say it's a way to call the methods from JHML subclasses as JHTML content, bootstrap, string, so as exp: variable = JHtml::_(string.truncate) ?> is like you type variable = JHtmlString->truncate(); ?> so i understand this way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With