I will have to look at custom fields later - maybe put the text there as a Javascript array or a PHP array and invoke it using eval().
For now I have implemented it using the following PHP functionSee later post for latest version:
static function showFieldHelp($fieldname, $label=null, $content=null, $helpIcon='<img src="images/mysite/help-icon2-15.png" alt="help"/>') {
switch ($fieldname) {
case 'TO BE REPLACED1':
$helpText = 'Help under construction.';
break;
case 'TO BE REPLACED2':
$helpText = 'Help under construction.';
break;
case 'TO BE REPLACED3':
$helpText = 'Help under construction.';
break;
default:
return $content;
}
if (empty($content)) {
if (empty($helpIcon)) return null;
$content = $helpIcon;
}
$code = '
<script type="text/javascript">
do_nothing( function(){
$$(\'.tooltip_'.$fieldname.'\').each(function(element,index) {
var content = element.get(\'title\').split(\'::\');
element.store(\'tip:title\', content[0]);
element.store(\'tip:text\', content[1]);
});
var tooltip_'.$fieldname.' = new Tips($$(\'.tooltip_'.$fieldname.'\'),
{ className: \'mysite-tooltips\', showDelay: 0, hideDelay: 100, fixed: true, windowPadding: {x:10,y:10} });});
</script>';
return '<span class="hikashop-help-icon tooltip_'.$fieldname.'"
title="'.htmlspecialchars($label).' :: '.htmlspecialchars($helpText).'">'.$content.'<span>' . $code ;
}
This then gets called like this (e.g. in the address form.php):
echo '<td class="key">';
// Hover over label help
echo comMyHikashopHelper::showFieldHelp('L_'.$fieldName, $oneExtraField->field_realname,
$this->fieldsClass->getFieldName($oneExtraField));
echo '</td>';
... etc ...
echo $this->fieldsClass->display($oneExtraField,$this->address->$fieldName,'data[address]['.$fieldName.']');
// Hover over help icon
echo comMyHikashopHelper::showFieldHelp($fieldName, $oneExtraField->field_realname);
Next refinement would be to put the help text
($helpText) into a language file instead of in the php code.
The ideal solution would be if the text and icon image came from the
$oneExtraField object.