0

We have a 3rd party event manager who scans bar codes, so it is great that civiCRM renders barcodes on events.

Our problem is that the 3rd party cannot process a barcode that contains a hyphen. For the event badge, we see that the barcode contains the contactID-registrationID

How can we remove the hyphen from the barcode?

We running version 4.7.16 on Joomla 3.6.5

1

A better approach would probably to use the Barcode hook and alter the value in there instead of overriding the core file.

https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterBarcode/

1

Customizing your Badge Value:

To make it simple for someone, Let me explicitly tell the solution for this implementation in Joomla (found through many hours of trial and error testing :).

  1. First make sure the field you want to show on the badge is defined in the list under the label (Administrator\CiviEvent\Event Name Badge Layouts).

  2. create a hook, which is basically a .php file and copy the following code with whatever the variables you want to show in the barcode (inside PHP tags ofcourse) (here in my case I am showing a custom value)*:

function joomla_civicrm_alterBarcode(&$data, $type, $context ) { if ($type == 'barcode' && $context == 'name_badge') { // change the encoding of barcode $data['current_value'] = $data['custom_6']; } }

  1. Save it under any name in the a new folder inside media. eg: \media\civicrm\customphp\civicrmHooks.php

  2. Go to Civicrm and define your PHP folder (Administrator\System Settings\Directories) : Custom PHP Directory - [civicrm.files]/customphp/

  3. Now go and find a Event Participant and click on the Badge Print and check the PDF printed. It should have the correct barcode.

  4. I could not find a civicrm way to find the name of the custom field name so what I did was to add the following php code in civicrmHooks.php and go to the badge print page, where it output the variable name list.

foreach($data as $x=>$x_value) { echo "Key=" . $x . ", Value=" . $x_value; echo "
"; }

0

I found on the page /administrator/components/com_civicrm/civicrm/CRM/Badge/BAO/Badge.php

line 273:

$data['current_value'] = $formattedRow['values']['contact_id'] . '-' . $formattedRow['values']['participant_id'];

I changed that to:

$data['current_value'] = $formattedRow['values']['contact_id'] . $formattedRow['values']['participant_id'];

removing the hyphen '-'.

I realize that is a hack since it affects core...

Any suggestions for a better approach?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.