Buy Now
Sign in

Barcode Generator worked in V4 but V5

amheng5 , May 01 2016
a
amheng5

I've been using Chronoforms V4 for many years ans have used the Barcode generator without any problems under V4. However with the recent change to Joomla 3.5 and the need to upgrade Chronoforms V5 I can't seem to get the custom code provided to work under V5 to generale the barcode.

The custom field php code that worked great under CCV4 follows:

				<?php
if ( !$mainframe->isSite() ) { return; }
/*
function to generate a random alpha-numeric code
using a specified pattern
*
* @param $pattern string
* @return string
*/
function generateIdent($pattern='9999999')
{
$alpha = array("A","B","C","D","E","F","G","H",
"J","K","L","M","N","P","Q","R","S","T","U","V","W",
"X","Y","Z");
$digit = array("1","2","3","4","5","6","7","8","9");
$return = "";
$pattern_array = str_split($pattern, 1);
foreach ( $pattern_array as $v ) {
if ( is_numeric($v) ) {
$return .= $digit[array_rand($digit)];
} elseif ( in_array(strtoupper($v), $alpha) ) {
$return .= $alpha[array_rand($alpha)];
} else {
$return .= " ";
}
}
return $return;
}
?>
<p>Registration ID</p>
<?php
$ident = generateIdent();
echo "<img src='".JURI::base()
."components/com_chronoforms/includes/barcode.php?barcode="
.$ident."&width=320&height=80' />";
?>


You'll notice I would change the red highlighted code to reflect the correct folder directory for CCV5 (chronoforms5}.

I've made sure the barcode.php was added to the cc5 directory. But when I go to view the form, the
first thing I notice is all the formatting is stripped and the remaining Actions such as captcha and submit buttons are removed and no barcode generated.

I've noticed that under CCV5, the custom code field does not include all the fields that are under CCV4 see attached. Field Name and Field ID are missing under CCV5.

Your assistance is appreciated.
Thanks

Attachments
CaptureV4.PNG
CaptureV4.PNG
(14.28 KiB)
203 Downloads/Views
CaptureV5.PNG
CaptureV5.PNG
(14.73 KiB)
187 Downloads/Views
GreyHead

Hi amheng5,

I think that the problem is the second line - later versions of Joomla! use a different check code. This works for me in CFV5 and Joomla! 3.5

				<?php
defined('JPATH_PLATFORM') or die; // change this line
/*
function to generate a random alpha-numeric code
using a specified pattern
*
* @param $pattern string
* @return string
*/
function generateIdent($pattern='9999999')
{
$alpha = array("A","B","C","D","E","F","G","H",
"J","K","L","M","N","P","Q","R","S","T","U","V","W",
"X","Y","Z");
$digit = array("1","2","3","4","5","6","7","8","9");
$return = "";
$pattern_array = str_split($pattern, 1);
foreach ( $pattern_array as $v ) {
if ( is_numeric($v) ) {
$return .= $digit[array_rand($digit)];
} elseif ( in_array(strtoupper($v), $alpha) ) {
$return .= $alpha[array_rand($alpha)];
} else {
$return .= " ";
}
}
return $return;
}
?>
<p>Registration ID</p>
<?php
$ident = generateIdent();
echo "<img src='".JURI::base()
."components/com_chronoforms5/extras/barcode/barcode.php?barcode="
.$ident."&width=320&height=80' />";
?>
Note also that I have the barcode,php file in components/com_chronoforms5/extras/barcode/ - you may need to edit that path.

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much