adding more info click to custom fields?

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 4 months ago #20065

Try to add the doextra = false; line in the }else if(obj.id=='user_choice_activate_plan_iq_phone'){ and else if(obj.id=='user_choice_activate_phone'){ blocks.

Please Log in or Create an account to join the conversation.

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
13 years 4 months ago #20282

I have a similar requirement.
Could the following parameters be added to custom field definitions:

Help Text
Help Link
Help Image

How these are used could be left to the customised views.
This will allow text / link / image changes to be made through the admin screens and not in the code.

As a further refinement the default shipped views could be enhanced as follows:

(1) Help text - entered, link - null, image - null
Hover over label displays text in popup.

* (2) Help text - entered, link - null, image - entered
Hover over (or click) image displays text in popup.

(3) Help text - null, link - entered, image - entered
Show image after field.
Click image opens help page (further options needed?).

(4) Help text - entered, link - entered, image - entered
Show image after field.
Click image opens help page (further options needed?).
Hover over image shops the text.

(5) Help text - entered, link - entered, image - null
Show text as a link after field.
Click text opens help page (further options needed?).

* this is the one I have an immediate requirement for.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 4 months ago #20297

Maybe you could use the new "custom text" type of custom fields to add some text (and/or HTML) on the forms ? It won't be displayed in a popup bu directly in the form but that might be even for what you're trying to do ?

Please Log in or Create an account to join the conversation.

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
13 years 4 months ago #20329

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.

Last edit: 13 years 4 months ago by brainforge.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 4 months ago #20343

You should be able to do that by adding new columns in the hikashop_field table and then editing the file form of the view field to add some input fields for them.

Please Log in or Create an account to join the conversation.

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
13 years 4 months ago #20370

Thanks, will look in more detail later.

Please Log in or Create an account to join the conversation.

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
13 years 4 months ago #20374

Works great thanks.
Would it be useful to add into Hikashop core?
Can be left to custom views to decide how they are used.
Changes attached.

File Attachment:

File Name: changes.zip
File Size:3 KB

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
13 years 4 months ago #20375

Simplified my earlier showFieldHelp() routine, now looks like this.
Satisifies my current requirements, may need more refinement later on.

static function showFieldHelp($fieldname, $field, $content=null, $hideicon=false) {
    if (empty($field->field_help_text) && empty($field->field_help_icon) && empty($field->field_help_link)) return $content;
    if ($hideicon) $helpIcon = null;
    else if (empty($field->field_help_icon)) $helpIcon='<img src="images/mysite/help-icon2-15.png" alt="help"/>';
    else $helpIcon='<img src="' . $field->field_help_icon . '" alt="help"/>';
    if (empty($content)) {
      if (empty($helpIcon) || $hideicon) {
        if (empty($field->field_help_link)) return null;
        $content = $field->field_help_link;
      }
      else $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($field->field_realname).' :: '.htmlspecialchars($field->field_help_text).'">'.$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,
       $this->fieldsClass->getFieldName($oneExtraField), true);
  echo '</td>';
... etc ...
  echo $this->fieldsClass->display($oneExtraField,$this->address->$fieldName,'data[address]['.$fieldName.']');
  // Hover over help icon
  echo comMyHikashopHelper::showFieldHelp($fieldName, $oneExtraField);
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.

Last edit: 13 years 4 months ago by brainforge.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 4 months ago #20404

Sounds great. We'll look at adding that for next release.
We will probably want to include the showFieldHelp function in the file administrator/components/com_hikashop/classes/field.php
so that getFieldName and display can directly use it without having to change all the views.

For the translation, it should also be able to use the trans function of that same file in order to translated the text via the translation files.

Please Log in or Create an account to join the conversation.

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
13 years 4 months ago #20423

Good to hear you will be looking into adding that into the core code.

It has since occurred to me that the ability to add custom fields to the field table itself (probably a confusing concept :woohoo: ) could be quite a powerful feature - up to view coders to decide what they might want to do with any such fields.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 4 months ago #20445

That's indeed an interesting idea as well. We'll add that to the todo list.

Please Log in or Create an account to join the conversation.

Time to create page: 0.074 seconds
Powered by Kunena Forum