I am trying to bring a rather complicated booking form into MODX and am having issues with one aspect of the PHP.
We have a function that looks at the tourcode value and depending on the first two letters chooses which T&C to display. The tourcodes are basically 3 letters and 3 or 4 numerals (tha1302, akh121, bhm134, etc). The PHP function I can't seem to incorporate uses substr to strip out the first two characters.
The original PHP version used in our old non-CMS website:
$trip = substr($tourcode, 0, 2);
if ($trip == bh) { include "/...../terms60.inc"; }
else { include "/...../terms45.inc"; }
The proposed MODX version:
$trip = substr($tourcode, 0, 2);
if ($trip == bh) { $modx->setPlaceholder('tandc', 'tac60'); }
else { $modx->setPlaceholder('tandc', 'tac45'); }
In MODX the 'tandc' value always defaults to the 'tac45' no matter what tourcode I use. In PHP it works as expected. So I am guessing there is some issue with snippets vs php that I haven't accounted for.
And yes I am sure that the $tourcode value is present as it is used successfully elsewhere in the same snippet.