Translate Custom field Checkbox value

  • Posts: 88
  • Thank you received: 19
7 years 2 months ago #260996

-- HikaShop version -- : 3.0.0

Hi

I have a custom field of type checkbox with label: COLOR
I have a value and title within called BLACK

My translation works fine in backend, but in frontend where I output the content, it's not getting through.

Here's my code:

<ul class="list">
<?php 
	$color = explode(",",$this->element->color);
	foreach ($color as $key => $value) {
		echo '<li>';
		$myField = $fieldclass->get('17');
		echo $myField->field_value[$value]->value;
		echo '</li>';
	}
?>
</ul>

EDIT: if I use this echo in my foreach, it works:
echo JText::_($myField->field_value[$value]->value);

Perhaps there are better ways?

EDIT: Sorry about wrong category for topic...

Thanks

Last edit: 7 years 2 months ago by dyvel.

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
7 years 2 months ago #261008

Hi,

When you want to display a custom field ; the best is to use the function provided by the custom field class ; like it is done in current HikaShop view :

echo $fieldsClass->show($field, $value);
It will support every kind of custom field and perform the translation for you.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Time to create page: 0.058 seconds
Powered by Kunena Forum