0

I am a newbies in Drupal, currently I use Drupal 7.

I want to add one button into content type, to make the phone call when user click on this button.

I use module Button Field + Rule, but I don't know how to Rule create action like the link

<a href="tel:1-847-555-5555">1-847-555-5555</a>

Anyone can help me?

Thanks

1
  • You don’t need modules for this - it’s just basic HTML.
    – Kevin
    Sep 11, 2018 at 11:04

1 Answer 1

0

I'm not sure the desired functionality is achievable via Button Field + Rules.
What you need is to create a plain text field to store the phone number, then you need to override the field template in your theme to output it as a link.
For example, if you field name is telephone_link, then you should create a file field--telephone_link.tpl.php under the folder YOUR_THEME/templates/field with the following content:

<div class="<?php print $classes; ?>"<?php print $attributes; ?>>
  <?php if (!$label_hidden): ?>
    <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
  <?php endif; ?>
  <div class="field-items"<?php print $content_attributes; ?>>
    <?php foreach ($items as $delta => $item): ?>
      <a href="tel:<?php print $item['#markup'];?>" class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?></a>
    <?php endforeach; ?>
  </div>
</div>
1
  • Thank @Ismail Cherri, it is really useful for me, thank you so much.
    – Alden
    Sep 12, 2018 at 1:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.