I wrote this button for a project and I thought it might help someone else so I decided to share it instead to leave it in one of my custom modules.

Patch attached in my next comment.

Regards.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gnuget created an issue. See original summary.

gnuget’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
2.48 KB

Patch attached.

nedjo’s picture

Category: Task » Feature request

Thanks, this will indeed be useful for others.

Sharing via email has some complexities in that we need to know what email(s) to send to and may want for example a default email that goes out. Rather than providing a simple email link, another option would be to integrate with Forward, which handles a lot of the harder problems. That's what was done for example in the Service Links module in Drupal 7 to provide a mail forwarding link. We can't use that code directly, but it might be useful as a model.

flocondetoile’s picture

Thanks @Gnuget.

Yes, providing a default email body based on the current entity could be useful. Quickly look at Forward module. Seems that this could be "easily" integrated if we build a link based on the forward module route : /forward/{entity_type}/{entity}.

gnuget’s picture

Status: Needs review » Needs work

Looks great the Forward module.

I will try to work on this, this week.

mlncn’s picture

Status: Needs work » Needs review

I think the option as is should go in; integration with the forward module could be optional if the forward module is available.

Not sending the e-mail ourselves, but opening it in the visitor's e-mail program, can be seen as a *feature* in that it avoids opening a potential avenue for a site being used in sending spam.

nedjo’s picture

+++ b/src/SocialNetwork/Mail.php
@@ -0,0 +1,74 @@
+  const MAIL = 'mailto:theemail@email.com';

Just from looking at the code, it looks like the email would be addressed to theemail@email.com and in their email program a user would need to delete that email address and then select the one they want to use. If so that seems like a usability issue.

gnuget’s picture

FileSize
387 bytes
2.46 KB

While I have the time to work on the Forward module integration I just removed the default mail fixing the usability problem mentioned by Nedjo on #7.

Patch attached.

David.

gnuget’s picture

Hi!

Today I finally was able to work on this.

On this patch the following changes:

  • I fixed a few issues in the social_simple.js file, I basically added the `once` method to avoid binding several times the click event.
  • I added a variable called open_popup, in the case of the Mail button we no need to open a popup.
  • I reindented the file following the drupal coding standard.
  • I added coded to integrate this module with the Forward module

I think this is almost ready to be committed :-)

Let me know.

Thanks!

flocondetoile’s picture

Hi @gnuget

Sorry for the delay, I was busy on some others projects.
Your patch looks very fine.
Commited.

I just updated this part to add the page title on the mail body too.

$options = [
      'query' => [
        'body' => PHP_EOL . $title . PHP_EOL . $share_url,
        'subject' => $title,
      ],
      'absolute' => TRUE,
      'external' => TRUE,
    ];

Thanks for your work.
And I thank you for your nice and useful blog post (I set a link on the module page)

flocondetoile’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.