Keyword

Turn radio buttons and multi-select list into link

More
12 years 3 months ago #66997 by CHAR
Can someone tell me how turn the extra fields in K2 like radio-buttons and multi-select items into links?
Currently, my labels work as links. Below is my code...


if ($rows[$i]->id == $object->id)
{

if ($rows[$i]->type == 'textfield' || $rows[$i]->type == 'textarea' || $rows[$i]->type == 'date')
{
$value = $object->value;
if ($rows[$i]->type == 'date' && $value)
{
$offset = (K2_JVERSION == '16') ? null : 0;
$value = JHTML::_('date', $value, JText::_('K2_DATE_FORMAT_LC'), $offset);
}

}
else if ($rows[$i]->type == 'labels')
{
$labels = explode(',', $object->value);
if (!is_array($labels))
{
$labels = (array)$labels;
}
$value = '';
foreach ($labels as $label)
{
$label = JString::trim($label);
$label = str_replace('-', ' ', $label);
$value .= '<a href="'.JRoute::_('index.php?option=com_k2&view=itemlist&task=search&searchword='.urlencode($label)).'">'.$label.'</a> ';
}

}
else if ($rows[$i]->type == 'select' || $rows[$i]->type == 'radio')
{
foreach ($json->decode($rows[$i]->value) as $option)
{
if ($option->value == $object->value)
{
$value .= $option->name;
}

}
}
else if ($rows[$i]->type == 'multipleSelect')
{
foreach ($json->decode($rows[$i]->value) as $option)
{
if (@in_array($option->value, $object->value))
{
$values[] = $option->name;
}

}
$value = @implode(', ', $values);
}

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum