Skip to main content

Text Output Change from Checkboxes

More
11 years 1 month ago #211602 by ninjab
-- HikaShop version -- : 2.5.0

Hi there,

I have added a customfield checkbox selection for the backend to select a colour, and the data is outputted on the front end as just text (which is what I want it to do). What I am wanting to know, is how to I add a space after the data as its having commas without spaces between each colour name?

For example, the output is outputting this at the moment:
Red,Blue,Green

And I am wanting to show like this:
Red, Blue, Green.

I assume the change would need to be done in PHP?

My alternative option is just change the customfield to a text box and enter the colours in manually but I'd prefer not to.

Many thanks.

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

More
11 years 1 month ago #211633 by nicolas
Hi,

Here is the code which handles the display of the checkbox custom fields values on the frontend:
take.ms/vbwVo
It's in the file administrator/components/com_hikashop/classes/field.php
As you can see, the separator there is already a comma followed by a space. So that should already be the case, unless that code has been changed on your website or something else is modifying the output.
Could you provide a link to a product page with the issue so that we can look at it ? Can you also check that the code in the field.php is correct ?

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

More
11 years 1 month ago - 11 years 1 month ago #211643 by ninjab
Hi Nicholas, thankd for the reply.

I have it only on a localserver at the moment with wamp.

Its strange, I found the code you mentioned and it had the space. But doesnt seem to generate like that.

This is the code here:
Code:
class hikashopCheckbox extends hikashopRadioCheck { var $radioType = 'checkbox'; function display($field, $value, $map, $inside, $options = '', $test = false, $allFields = null, $allValues = null){ if(!is_array($value)){ $value = explode(',',$value); } return parent::display($field,$value,$map,$inside,$options,$test,$allFields,$allValues); } function show(&$field,$value){ if(!is_array($value)){ $value = explode(',',$value); } if(!empty($field->field_value) && !is_array($field->field_value)){ $field->field_value = $this->parent->explodeValues($field->field_value); } $results = array(); foreach($value as $val){ if(isset($field->field_value[$val])) $val = $field->field_value[$val]->value; $results[] = parent::show($field,$val); } return implode(', ',$results); }

Thanks.
Last edit: 11 years 1 month ago by ninjab.

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

More
11 years 1 month ago #211678 by nicolas
Hi,

Then I'm afraid we'll have to look at the issue directly on the page. Could you put it temporarily online so that we could access it ?

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

Time to create page: 0.171 seconds
Powered by Kunena Forum