I have used the Joomla Component Creator to make a component and a module.
Now I'm trying to modify the output of the module.
I can use
echo ($element->my_field)
to echo the value of my field in the module. But I cannot figure out how to echo the field label.
In helper.php there is a function to render headers which looks like this:
public static function renderTranslatableHeader(&$params, $field)
{
return JText::_(
'MOD_VECKOMATSEDEL_HEADER_FIELD_' . str_replace('#__', '', strtoupper($params->get('table'))) . '_' . strtoupper($field)
);
}
I create this variable in my module
$label = ModVeckomatsedelHelper::renderTranslatableHeader($params, $params->get('field'));
if I then echo $label it echoes the label of the first field in the table.
How can I pass the field name as an argument?
My guess was echo $label->my_field but that's not correct.
$element = ModMyModuleHelper::getItem($params);
Printing that array gives both the field label and the field value, butprint_r ($element->my_field)
will only print the field value.$element
or thegetItem($params)
source code?print_r ($element)
gives me:stdClass Object ( [id] => 15 [asset_id] => 153 [ordering] => 12 [state] => 1 [checked_out] => 0 [checked_out_time] => 0000-00-00 00:00:00 [created_by] => 36 [mon_lunch] => Good meal)
public static function getItem(&$params) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $vecka = date(W); /* @var $params Joomla\Registry\Registry $query ->select('*') ->from($params->get('item_table')) ->where('vecka = ' . intval($vecka)); $db->setQuery($query); $element = $db->loadObject(); return $element; }