Answers.Body: <p>Customizing your Badge Value:</p>
  <p>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 :).</p>
  <ol>
  <li><p>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).</p>
  </li>
  <li><p>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)*:</p>
  </li>
  </ol>
  <p>function joomla_civicrm_alterBarcode(&amp;$data, $type, $context ) {
  if ($type == 'barcode' &amp;&amp; $context == 'name_badge') {
  // change the encoding of barcode
  $data['current_value'] = $data['custom_6'];
  }
  }</p>
  <ol>
  <li><p>Save it under any name in the a new folder inside media. eg: \media\civicrm\customphp\civicrmHooks.php</p>
  </li>
  <li><p>Go to Civicrm and define your PHP folder (Administrator\System Settings\Directories) : Custom PHP Directory -  [civicrm.files]/customphp/</p>
  </li>
  <li><p>Now go and find a Event Participant and click on the Badge Print and check the PDF printed. It should have the correct barcode.</p>
  </li>
  <li><p>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.</p>
  </li>
  </ol>
  <p>foreach($data as $x=&gt;$x_value)
  {
  echo &quot;Key=&quot; . $x . &quot;, Value=&quot; . $x_value;
  echo &quot;<br>&quot;;
  }</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-15T04:30:11.880Z
Answers.LastActivityDate: 2021-08-15T04:30:11.880Z
Answers.UserDisplayName: sri
Answers.Body: <p>A better approach would probably to use the Barcode hook and alter the value in there instead of overriding the core file.</p>
  
  <p><a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterBarcode/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterBarcode/</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-24T14:19:31.363Z
Answers.LastActivityDate: 2017-03-24T14:19:31.363Z
Answers.UserDisplayName: Parvez Saleh
Answers.Body: <p>I found on the page /administrator/components/com_civicrm/civicrm/CRM/Badge/BAO/Badge.php</p>
  
  <p>line 273:</p>
  
  <pre><code>$data['current_value'] = $formattedRow['values']['contact_id'] . '-' . $formattedRow['values']['participant_id'];
  </code></pre>
  
  <p>I changed that to:</p>
  
  <pre><code>$data['current_value'] = $formattedRow['values']['contact_id'] . $formattedRow['values']['participant_id'];
  </code></pre>
  
  <p>removing the hyphen '-'.</p>
  
  <p>I realize that is a hack since it affects core... </p>
  
  <p>Any suggestions for a better approach?</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-24T14:00:18.883Z
Answers.LastActivityDate: 2017-03-24T14:00:18.883Z
Answers.UserDisplayName: A. Block
Body: <p>We have a 3rd party event manager who scans bar codes, so it is great that civiCRM renders barcodes on events.</p>
  
  <p>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</p>
  
  <p>How can we remove the hyphen from the barcode? </p>
  
  <p>We running version 4.7.16 on Joomla 3.6.5</p>
  
Tags: <civievent>
Title: How can we modify the default event badge barcode?
ThreadText: # How can we modify the default event badge barcode?
  
  (Asked by: username_0 on 2017-03-24)
  
  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
  
  **Tags:** civievent
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2021-08-15. Score: 2
  
  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 "  
  ";
  }
  
  
  ---
  
  ### Answer by username_2 on 2017-03-24. Score: 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/>
  
  
  ---
  
  ### Answer by username_0 on 2017-03-24. Score: 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?
  
  
  ---
  
  